Forum Discussion

AverageAsker's avatar
AverageAsker
Helper I
10 years ago

Convert DateTimeOffset to DateTime

Hi, my data source is SQL table containing DateTimeOffset column, I need the date-time stored there to be displayed in the report as a date-time converted by using the time zone's offset stored in the column of another table, how do I do that? Or, to make the question simpler - how do I apply any date time conversion to the date time stored in a table's column while it is displayed in the report?

I am complete novice in Power BI, please give me a direction.

11 Replies

    • AverageAsker's avatar
      AverageAsker
      Helper I

      Thanks, what/where do I do to insert that code? I am currently using Power BI Desktop, I clicked Get Data and then specified SQL Server, then provided connection info and imported the table I was interested in. My table User consists of few columns:

       

      • CreatedDate (the data in this column stored in UTC.)
      • InternalIdentifier (string - unique value per row)
      • Type (contains few possible values of type TINYINT)

       

      I want to see a chart(s) showing users' distribution in time (taking Type into accoun) where the Time will be converted to a certain offset.

      In my Power BI Desktop I saw the table (User) I imported and its fields, so I did right click over CreatedDate but could not find there anything enabling me to put any code/script which would change the formatting.

       

      Right click over CreatedDate column

       

      Can you briefly explain and/or point me to the documentation which would show where is that "connection" point enabling me to add code/script so it is associated with the DB columns displayed in the report?

       

      One more connected question - am I supposed to use Power Query only or it is possible to use .NET languages as well?

      • ImkeF's avatar
        ImkeF
        Community Champion

        So we only have one table: user. Right?

        Where does that offset-value come from?

        Another column or is it a fixed value or some conditional values?

         

        Pictures of data or data model would help!

        Before: ...

        After: ...