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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
winter69
New Member

Convert C# date ticks to DateTime

Is it possible to convert a column in Power BI that contains a C# Date tick value to a DateTime?

2 ACCEPTED SOLUTIONS

I am sure you could do it in Power Query. 

 

Read this. http://stackoverflow.com/questions/1489243/how-can-i-convert-ticks-to-a-date-format

 

in Power Query, add a new column and then use the formula, above to convert the date tick to a serial number

 

I think you can then convert the number to a date with the UI (although I have never tried it).  Worst case you should be able to use a power query date fipunction to convert it. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

Thanks Matt.  I suspected this was the direction I needed to go in, just wanted to be sure I hadn't missed something obvious.

View solution in original post

4 REPLIES 4
hugoberry
Responsive Resident
Responsive Resident

Try the following conversion

=DateTime.FromFileTime([ticks])-#duration(584388,0,0,0)

 

The FromFileTime counts the ticks from 1600/01/01 so that's why we have the duration of 584388 days to offset this.

bradnywells
New Member

Check this one, more about....date conversion

 

Wells

I am sure you could do it in Power Query. 

 

Read this. http://stackoverflow.com/questions/1489243/how-can-i-convert-ticks-to-a-date-format

 

in Power Query, add a new column and then use the formula, above to convert the date tick to a serial number

 

I think you can then convert the number to a date with the UI (although I have never tried it).  Worst case you should be able to use a power query date fipunction to convert it. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Thanks Matt.  I suspected this was the direction I needed to go in, just wanted to be sure I hadn't missed something obvious.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.