Forum

Notifications
Clear all

Text to Date

4 Posts
2 Users
0 Reactions
123 Views
(@evdheever)
Posts: 6
Active Member
Topic starter
 

Hi

 

In a Data export the Date in the data set is as follows

Data Type:  Text

201506  indicating YYYYMM

 

How do I convert to Dates in MMM-YY format in Power Query, please?

I've tried to change the Data Type to Date, but get an Error.

 

Please advise.

Thank you

Eduard

 
Posted : 29/06/2017 6:57 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Eduard,

You can use the text functions to build a valid date, then format it: https://msdn.microsoft.com/en-us/library/mt296604.aspx

=Date.ToText(Date.From("01/"&Text.End([date],2)&"/"&Text.Start([date],4)),"MMM-yyyy")

 
Posted : 29/06/2017 11:26 pm
(@evdheever)
Posts: 6
Active Member
Topic starter
 

Hi Catalin

Thanks, it results in the correct formatSmile

However, the resulting dates are incorrect - it defaults all the dates to Jan-2015 or Jan-2016.

How do we need to change the formula to rectify that, please?

Thank you

Eduard

 
Posted : 30/06/2017 11:11 am
(@catalinb)
Posts: 1937
Member Admin
 

You have to be careful to the date format you build: I used "01/" as the first part of the string, and obviously it should represent the missing part of the date: day, in a dd/mm/yyyy format. If you have mm/dd/yyyy date format, you have to put month first in the string :), or specify the culture: en-US, en-AU, or any.

You have to get used to go the library: https://msdn.microsoft.com/en-us/library/mt260703.aspx

 
Posted : 30/06/2017 3:31 pm
Share: