The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

How can I convert an Epoch timestamp to a timestamp using SQL Anywhere?

For example: Input Epoch timestamp: 1354320000

Desired output Timestamp: 2012-12-01 00:00:00

Human time (GMT): Sat, 01 Dec 2012 00:00:00 GMT

asked 07 Dec '12, 13:53

sybasetester's gravatar image

sybasetester
513310
accept rate: 0%


EPOC time is the number of seconds since 1970 Jan 1.... so use:

select dateadd( SECOND, 1354320000, '1970-1-1' )
permanent link

answered 07 Dec '12, 15:01

Mark%20Culp's gravatar image

Mark Culp
22.3k9129262
accept rate: 40%

edited 07 Dec '12, 15:02

Mark your answer has the extra ".000000"

I think this is what I need to do, right?

--CONVERT FROM EPOCH TO DATETIME:

SELECT DATEFORMAT(dateadd(SS,CONVERT(INT, 1354320000), CAST('1970-01-01 00:00:00' as datetime) ), 'yyyy-mm-dd hh:mm:ss') as myDateTime;

---CONVERT FROM DATETIME TO EPOCH GMT+0:

SELECT CAST(datediff(ss, 'Jan 01 1970', '2012-12-01 00:00:00' ) AS CHAR) as myEpochDate;

permanent link

answered 07 Dec '12, 15:36

sybasetester's gravatar image

sybasetester
513310
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×60
×21
×14

question asked: 07 Dec '12, 13:53

question was seen: 27,765 times

last updated: 07 Dec '12, 15:36