0

My coredata sqlite table "SQLTABLE" contains a tuple of type timestamp "ZTIMESTAMP" as 123456789

How can I read it using sql (not obj C) and convert it to a date ?

Ecko123
  • 308
  • 1
  • 4
  • 16

1 Answers1

1
SELECT strftime('%Y-%m-%d-%H:%M', ZTIMESTAMP, 'unixepoch') as time from SQLTABLE

Sqlite allows you to format time that is a UNIX time timestamp.
You can test this in a SQL Browser tool locally. To check your query and I think you can change "unixepock" to "local-time" for the time in your local time.

John Ballinger
  • 7,380
  • 5
  • 41
  • 51
  • The problem is that I'm not able to get correct date out of it. If I put in unixepoch the time is shown to be 10 yrs back If not then it is shown to be 40 years ahead – Ecko123 Mar 17 '14 at 07:21
  • I think we are getting close, can you paste an actual time stamp value in and what you think it should be. You probably can add some value to the timestamp to make it work correctly, once you figure out what the timestamp is and what it should be. – John Ballinger Mar 17 '14 at 07:56
  • Just resolved it , the issue was some additional constant value being added to the the original timestamp. Thanks – Ecko123 Mar 17 '14 at 09:26
  • Say @Ecko123, can you share how you adjusted for said constant? What was it? – Scott Corscadden Nov 24 '14 at 16:27