Datetime: epoch into Date time format

Hello, I have some problems with the converting of “epoch/unix” into a datetime format

Example:
epoch: 1566162000000
result datetime: 19.08.2019 00:00:00

Problem:
The time is missing and I do not know why.

Formel
DATETIME([epoch]/86400/1000+“01/01/1970 00:00”)

Thanks a lot

1 13 1,551
13 REPLIES 13

Steve
Platinum 4
Platinum 4

A DateTime plus a Number advances the DateTime by Number days, not seconds.

Danke / Thanks

I need you support…

What I have:
Epoch:1566179000000 (milliseconds)
Datetime: Monday, August 19, 2019 1:43:20

Result with following formel:
8/19/2019 2:00:00 AM
DATETIME( Number([Epoch]/86400/1000 ) + Datetime(Day( “01.01.1970”)))

Problem: The time is not correct

Thanks for helping out

Try:

Datetime(“01/01/1970”) + Number([Epoch] / 86400 / 1000)

Literal Date values in expressions must be formatted as MM/DD/YYYY; other formats are not recognized as Date values in expressions.

Test it: 8/19/2019 12:00:00 AM Time not ok

What should the correct result be?

Monday, August 19, 2019 1:43:20

Ah, then we’re back to my original response:

Where do you expect the time to come from?

IF you convert this “epoch” 1566179280000 via https://www.epochconverter.com/
Than you get the “Date time” as result.

thx

AppSheet is not epochconverter.com; AppSheet doesn’t work the same way.


ok thanks a lot

I know this is an old post, but I have been working on a similar problem: converting a date saved in the database as unix time stamp in seconds into an actual datetime in AppSheet.

The formula I achieved (after seveal attempts) is the following:

DATETIME(“01/01/1970”) +
FLOOR([reception_date] / (24*60*60)) +
(
  TIME(
    CONCATENATE(
      FLOOR( MOD([reception_date], 24*60*60) / (60*60) ),
      ":", 
      FLOOR( MOD([reception_date], 60*60) / 60 ),
      ":", 
      FLOOR( MOD([reception_date], 60) )
    )
  )
  - "00:00:00"
)
Explanation

DATETIME(“01/01/1970”): starting of Unix Epoch on January 1st, 1970 at UTC
FLOOR([reception_date] / (24*60*60)): number of whole days
FLOOR( MOD([reception_date], 24*60*60) / (60*60) ): hours
FLOOR( MOD([reception_date], 60*60) / 60 ),: minutes
FLOOR( MOD([reception_date], 60) ): seconds
CONCATENATE( <hours>, ":", <minutes>, ":", <seconds>): get a text representing the time
TIME(): convert text to time
- "00:00:00": convert time to duration (this is a trick I learnt from @Steve here: TIME() | AppSheet Help Center)

I hope it can be helpfull for next creators.

that works thanks

Top Labels in this Space