Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Converting timestamp fromI to Date/Time

How can I convert this data to a date, in our database I got this timestamp 1557280403.  It is from a SQL server.    help wanted 
  • blopez11's avatar
    7 years ago

    If the timestamp is seconds since 1/1/1970, you can use the use the following function, call it GetDateTimeFromSeconds, then add a step in your query to create a column, calling this function, and passing in your timestamp

     

    I can't take credit for this, got this from another helpful contributor to the community

     

    Hope it helps,

    //
    // ...This function takes in seconds from epoch and returns a value in datetimezone (UTC)
    //
    let
    Source = (seconds as number) =>
    let
    Result = #datetimezone(1970, 1, 1, 0, 0, 0, 0, 0) + #duration(0, 0, 0, seconds)
    in
    Result
    in
    Source

  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi 

    Thank you for the reply. 

    Can to translate it to DAX. (sorry but I am very new in this)