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
Thiyags
Helper II
Helper II

Converting from Text to Date

Hi I need to convert the following text into Date

 

Fri Nov 25 05:17:22 +0000 2016

 

Any idea

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@Thiyags

 

In this scenario, you can use PATHITEM() function to split the different date parts in the string into columns. Please refer to formulas below:

 

Month = PATHITEM(SUBSTITUTE(Table3[Column1]," ","|"),1)
Day = PATHITEM(SUBSTITUTE(Table3[Column1]," ","|"),2)
Time = PATHITEM(SUBSTITUTE(Table3[Column1]," ","|"),3)
Year = PATHITEM(SUBSTITUTE(Table3[Column1]," ","|"),4)

Then you can concatenate them and convert into datetime type.

 

Datetime = Table3[Month] & " " & Table3[Day] & " " & Table3[Year] & " " & Table3[Time]

98.PNG

 

Regards,

View solution in original post

3 REPLIES 3
v-sihou-msft
Employee
Employee

@Thiyags

 

In this scenario, you can use PATHITEM() function to split the different date parts in the string into columns. Please refer to formulas below:

 

Month = PATHITEM(SUBSTITUTE(Table3[Column1]," ","|"),1)
Day = PATHITEM(SUBSTITUTE(Table3[Column1]," ","|"),2)
Time = PATHITEM(SUBSTITUTE(Table3[Column1]," ","|"),3)
Year = PATHITEM(SUBSTITUTE(Table3[Column1]," ","|"),4)

Then you can concatenate them and convert into datetime type.

 

Datetime = Table3[Month] & " " & Table3[Day] & " " & Table3[Year] & " " & Table3[Time]

98.PNG

 

Regards,

@v-sihou-msft

 

Thanks for ur reply. This works perfectly

MarcelBeug
Community Champion
Community Champion

My suggestion would be to split the string.
Next step is to convert to date depending on your requirements:

Dated = ignore time zone

LocalDate = Local date, taking into account the time zone.

let
    Source = Text.Split("Fri Nov 25 05:17:22 +0000 2016"," "),
    Dated = Date.From(Source{1}&" "&Source{2}&", "&Source{5}),
    LocalDate = Date.From(DateTimeZone.From(Source{1}&" "&Source{2}&", "&Source{5}&", "&Source{3}&" "&Source{4}))

in
    Dated
or    LocalDate
Specializing in Power Query Formula Language (M)

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.