Forum Discussion

alitzellachner's avatar
alitzellachner
Frequent Visitor
3 years ago
Solved

Local to UTC conversion (summer/ winter time)

Hy,

another question for time appeared. I'm converting local to UTC time with summer/ winter time which works. At the end i make a text by

startdate= DateTime.ToText(convertLOCALtoUTCWithDST(start), "yyyy-MM-ddThh:mm:ssZ")

 

In the result he clears am/pm so 08:00 in the morning is the same as 20:00. Is there any solution for this?

 

Thank you,

Andreas

3 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Icon for Most Valuable Professional rankMost Valuable Professional

    I think you can directly use DateTimeZone.ToUtc or DateTimeZone.ToText

  • thx but in this case i get the same result "2023-03-01T06:00:00Z" and no distinction between summer and winter time. So the problem is the transformation ToText

     

    start= 01.03.2023 20:00:00 +02:00

    = DateTimeZone.ToText(DateTimeZone.ToUtc(start), "yyyy-MM-ddThh:mm:ssZ")

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi alitzellachner ,

    Please try replacing "hh" with "HH":

    startdate = DateTime.ToText(convertLOCALtoUTCWithDST(start), "yyyy-MM-ddTHH:mm:ssZ")
    

    Custom date and time format strings | Microsoft Learn

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum