lundi 29 juin 2015

JulianDay() and Strftime() returning null when calculating difference between two dates

I have problem in retrieving difference between two date columns from a table in SQLite Database . When i execute the query using CocoaMySQL MesaSQLite 3.0.9 I am getting 'NULL' as result. I have records with values for that columns. My query is

SELECT cast ( ( strftime('%s',t.timestamp2)-strftime('%s',t.timestamp1 ) ) AS real )/60/60 AS elapsed FROM timestamps AS t; SELECT (STRFTIME('%s',timestamp1) - STRFTIME('%s',timestamp2)) / -3600 from timestamps where objid= 3939

Result : Null

select timestamp1,timestamp2 from timestamps where objid = 3939.

Result :2014-01-29 02:55:00 AM 2014-01-29 03:00:00 AM ( means i have data in timestamps table)

SELECT julianday('now') - julianday('1776-07-04');

Result: 87287.5314

SELECT julianday(timestamp1) - julianday(timestamp2) from timestamps where objid =3939

Result: NULL value

'timestamp1' & 'timestamp2' are columns in 'timestamps' table .which have records with values.

Please give a solution to fix this issue ASAP. I am not able to add screen shots.

Aucun commentaire:

Enregistrer un commentaire