Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
webportal
Impactful Individual
Impactful Individual

Converting date MySQL database

I've imported a MySQL database from a PHP based CMS.

 

The dates in the database are formatted as integers.


For example:

 

2016-01-29 20:02 corresponds to:

1454097752

 

And:

 

2015-11-09 16:45 corresponds to:

1447087522

 

Now, I have the whole data in Power Pivot and I need to work with readable dates and I have no idea how to get them from integers as above.

 

Does anyone know of a conversion function I could use?

 

Thank you so much for your help!

5 REPLIES 5
ImkeF
Community Champion
Community Champion

This seems to be seconds since 1970.

So you can convert by adding a custom column with this formula

 

([NumberField]/24/60/60)+25569

 

 

This should return a number that you can then convert to Datetime.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

webportal
Impactful Individual
Impactful Individual

Hi,

 

It should be something like that, yes.

 

For 1481574249 which is 2016-12-12 20:24

 

The formula 

([NumberField]/24/60/60)+25569

 

Returns:

42716,8501014

 

And applying DATEVALUE to that number returns the error:

 

"Type mismatch"

 

PS: The field is set to Auto (Date) 

ImkeF
Community Champion
Community Champion

Hi,

I did this as a column-operation in the UI.

But if you want to do it via a formula, try Date.From(..) instead.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

webportal
Impactful Individual
Impactful Individual

I'm using a calculated column in Power Pivot.

 

=DATEVALUE([Date Column]/24/60/60+25569)
ImkeF
Community Champion
Community Champion

Wrong forum 😉

 

You can also apply a column operation there: Home -> Format -> Data Type: Date

 

Or again in a formula:

FORMAT([Spalte2]; "General Date")

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.