Forum

How to convert seve...
 
Notifications
Clear all

How to convert seven-digit ordinal date (YYYYDDD) to a gregorian date with Power Query

4 Posts
2 Users
0 Reactions
224 Views
(@kenny777)
Posts: 2
New Member
Topic starter
 

I am trying to figure out how to convert a column of ordinal dates to Gregorian, but I'm not at all proficient with M code.  I found the below on a Power BI forum that was flagged as a problem solved, but it returns the day after for each date (it adds the day number of the year to 1/1/YYYY).  Can anybody help me out with this, please?

Thanks!

Date.AddDays(Date.From(DateTimeZone.From("20" & Text.Start(Number.ToText(116343),2) & "-01-01")),Int64.From(Text.End(Number.ToText(116343),3)))

 
Posted : 08/08/2017 9:32 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Kenny,

I don't profess to understand Julian dates, but you could just add another Custom Column to adjust the date returned by the above formula by 1:

=Date.AddDays([date column],-1)

Then you can delete the column containing the incorrect date.

Mynda

 
Posted : 08/08/2017 11:12 pm
(@kenny777)
Posts: 2
New Member
Topic starter
 

Thanks!  I don't know why that didn't occur to me!  I had been trying to do it in the same column.

Thanks again!

 
Posted : 09/08/2017 8:05 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Kenny,

I thought for a second on how to edit the formula in the same column too, but I'm lazy and it was going to require learning how those date formats work. It was just easier to add another column 😉

Mynda

 
Posted : 09/08/2017 7:13 pm
Share: