简体   繁体   中英

Convert Unix Timestamp - Spotfire Analyst

I'm importing SQL data into Spotfire Analyst. All of the date and time fields are in the form of a Unix timestamp. What's the best way to convert this into an actual date format that I can manipulate in Spotfire?

Utilizing a calculated column you can calculate the datetime based on the UNIX epoch.

We simply add our seconds to the DateTime of the UNIX epoch (JAN 01 1970 00:00:00 UTC) to get the result. Below is an example of the UNIX time when I started writing this post.

DateAdd("second",1429733486,DateTime(1970,1,1,0,0,0,0))

The below is what should work for you:

DateAdd("second",[UNIX_TIMESTAMP_COLUMN],DateTime(1970,1,1,0,0,0,0))

Keep in mind these dates produced will be in the UTC timezone as per the JAN 1 1970 epoch. If you need them in your local time zone you may have to adjust accordingly with further DateAdd functions adding/subtracting time as per current conversions. Also, if you observe daylight savings time you may need to add some extra case logic to handle that as well.

Please let me know if you have any questions or need further clarification.

In 7.0 and later you can use

FromEpohTimeSeconds([UNIXDATE])

or

FromEpohTimeMilliseconds([UNIXDATE])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM