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
Keshavpooja
Frequent Visitor

Convert column from Datetimezone to Datetime - M Query

Hi Experts,

 

I am getting values from the source like '2021-02-10 20:48:24 +01:00' which has been assigned type 'DateTimeZone' in the Query Editor. I would like to store it as 'DateTime' format with the value as '2021-02-10 21:48:24'. I have tried few steps which didn't work. Could you pls help with the correct M query.

 

1. First I tried to assign it directly as DateTime type assuming that would work in the way I expected, but no luck.

 

2. Then I tried --> DateTimeZone.RemoveZone(DateTimeZone.SwitchZone([#"Date/Time Opened"],1))  -->  but didn't work either.

 

Thanks & Regards,

Kesavan.

 

 

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Please try this expression.

 

= DateTimeZone.RemoveZone([DTZ]) + #duration(0, DateTimeZone.ZoneHours([DTZ]),0,0)

 

mahoneypat_0-1633263599655.png

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

6 REPLIES 6
mahoneypat
Employee
Employee

Please try this expression.

 

= DateTimeZone.RemoveZone([DTZ]) + #duration(0, DateTimeZone.ZoneHours([DTZ]),0,0)

 

mahoneypat_0-1633263599655.png

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat,

 

That's superb. It works. Thanks a lot.

 

//Kesavan.

Fowmy
Super User
Super User

@Keshavpooja 

You can add zero as the parameter SwitchZone:

DateTimeZone.RemoveZone( DateTimeZone.SwitchZone([DateTime], 0))

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy 

 

If I add 0 as parameter as you suggested, it becomes '2021-02-10 19:48:24'. 

 

Something seems to be wrong here. It behaves wierd.

 

 

StefanoGrimaldi
Resident Rockstar
Resident Rockstar

simple change the column to data/time/timezone first, them change it back to date/time or date/time using locale, so that should work and give you the date/time in the format you want 





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Hi,

It does not work. Pls see the time closely. If i do like you said  i get only 20:48:24 but i would need 21:48:24

 

Kesavan.

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.