-1

i have a table named hello dot sqlite. It had a column with data type INTDATE and it contains value 635256000000000000. Now i want to insert this date into my core data so i must convert it into NSData. I have tried this Objective-C and sqlite's DATETIME type

sqlite datetime data type with iphone NSdate? i followed this too but didn't get it.

Am getting this table from server, so am maintaining it in local core data. Am having trouble in storing this INTDATE value into a NSDate object.

but didn't work. Do any body know how to convert it ?

Community
  • 1
  • 1
  • 1
    What did not work? What did you try, what was the result? – Mundi Jan 24 '14 at 14:04
  • Actually i have no idea how to do that. I tried int dateSold = sqlite3_column_int(statement, 2); NSDate *date = [NSDate date]; storeItemSale.dateSold = date; i want to store that dateSold into storeItemSale.dateSold – GouthamDevaraju Jan 24 '14 at 14:12

1 Answers1

0

There is no such thing as an INTDATE specification in SQLite. According to the documentation,

INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC.

Thus, you could convert it like this:

NSDate *date = [NSDate dateWithTimeIntervalSince1970:number];

The number you mention would sort of result in a valid date if you divide it by 100 million. You would have to start with a long long integer I guess. But it is a mute point because the data you quote seems to be faulty anyway.

Maybe you are reading the wrong field. It seems there is lot of confusion about basic concepts which you should first try to get straight. E.g. a "table named hello dot sqlite" is non-sensical. A "dot sqlite" thing could maybe be a database file, but certainly not a table. Also, you want to convert a date into the Objective-C class NSDate, not NSData.

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • NData oops it was a type error. and yes i agree lot of improvements are needed in my way of posing the questions, soon i'll improve it. Thanks for the answer. I understood the answer ur solution works. – GouthamDevaraju Jan 24 '14 at 15:29