locked
Power Query Language Functions to Convert a UTC Date/Time to MST RRS feed

  • Question

  • I need to convert an implicit UTC date/time value to a MST date/time value.  I thought that I could achieve this by converting to an ISO 8601 compliant text representation of the MST date/time value (see below) and then back to a date/time value, but it's not working ...

    DateTime.FromText( DateTime.ToText( [MIN_REVSN_RLSE_DTTM] ,"yyyy-MM-ddThh:mm:ss-07")) 

    Is this a bug?  Or, is there a better way to do this?


    Thursday, October 30, 2014 3:08 PM

Answers

  • That's a fixed duration. Why not just [MIN_REVSN_RLSE_DTTM] + #duration(0, -7, 0, 0)?

    EDIT: For what it's worth, I don't think PQ ever does anything with DST anyway. This has both good points and bad points.

    Thursday, October 30, 2014 3:46 PM

All replies

  • DateTimeZone.ToLocal(DateTime.AddZone([MIN_REVSN_RLSE_DTTM, 0))

    Here, DateTime.AddZone says that the timezone is UTC (ie has an offset of zero). Then we convert to local time.

    • Proposed as answer by Curt Hagenlocher Thursday, October 30, 2014 3:19 PM
    • Unproposed as answer by Mark Weisman Thursday, October 30, 2014 3:20 PM
    Thursday, October 30, 2014 3:19 PM
  • I don't want to convert to local time which is CDT or CST.  I want to convert directly from UTC to MST.
    Thursday, October 30, 2014 3:22 PM
  • That's a fixed duration. Why not just [MIN_REVSN_RLSE_DTTM] + #duration(0, -7, 0, 0)?

    EDIT: For what it's worth, I don't think PQ ever does anything with DST anyway. This has both good points and bad points.

    Thursday, October 30, 2014 3:46 PM
  • That does it!  I need to do some self-study about the concept of "duration" in the Power Query Formula Language Specification PDF.

    Thanks, Curt.

    Thursday, October 30, 2014 3:58 PM