cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bartus1 Regular Visitor
Regular Visitor

Can I convert this: [Fri May 24 13:58:31 2019] to date/time format?

I have this from external source:

 

Fri May 24 13:58:31 2019

 

Can I convert this to 'normal' datetime in Power BI?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Can I convert this: [Fri May 24 13:58:31 2019] to date/time format?

Hi,

I used Column by examples in the Query Editor so solve the problem.  Here is the M code generated

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type text}}),
    #"Added Custom Column" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine({Text.Middle([Date], 8, 2), Text.Middle([Date], 3, 5), Text.Middle([Date], 20)}), type text),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Added Custom Column", {{"Custom", type date}}, "en-IN"),
    #"Inserted Text Between Delimiters" = Table.AddColumn(#"Changed Type with Locale", "Text Between Delimiters", each Text.BetweenDelimiters([Date], " ", " ", 2, 0), type text),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Text Between Delimiters",{"Date"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Text Between Delimiters", "Time"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time", type time}}),
    #"Renamed Columns1" = Table.RenameColumns(#"Changed Type1",{{"Custom", "Date"}})
in
    #"Renamed Columns1"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Can I convert this: [Fri May 24 13:58:31 2019] to date/time format?

Hi,

The time stamp is between the date and the year.  Are you sure????


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
bartus1 Regular Visitor
Regular Visitor

Re: Can I convert this: [Fri May 24 13:58:31 2019] to date/time format?

Yep.  I'd nave not asked about it if it were different.

Super User
Super User

Re: Can I convert this: [Fri May 24 13:58:31 2019] to date/time format?

Hi,

I used Column by examples in the Query Editor so solve the problem.  Here is the M code generated

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type text}}),
    #"Added Custom Column" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine({Text.Middle([Date], 8, 2), Text.Middle([Date], 3, 5), Text.Middle([Date], 20)}), type text),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Added Custom Column", {{"Custom", type date}}, "en-IN"),
    #"Inserted Text Between Delimiters" = Table.AddColumn(#"Changed Type with Locale", "Text Between Delimiters", each Text.BetweenDelimiters([Date], " ", " ", 2, 0), type text),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Text Between Delimiters",{"Date"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Text Between Delimiters", "Time"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time", type time}}),
    #"Renamed Columns1" = Table.RenameColumns(#"Changed Type1",{{"Custom", "Date"}})
in
    #"Renamed Columns1"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 61 members 1,169 guests
Please welcome our newest community members: