Chris:
In your post above, the SQL you provided, did NOT include any DATEDIFF function, therefore, it is impossible to tell you exactly what is wrong.
BUT, I suspect, or put another way, I can guess, that a solution is easy. Let me explain. The two fields you want to perform the DATEDIFF on, must be TIMESTAMP fields . . . not just TEXT field that look like TIMESTAMP fields, but, actual TIMESTAMP field type.
So, please use the following example . . . that can be run EITHER with or withOUT the OpenOffice Base parser. To try it, just copy and paste the SQL below, and run it with OpenOffice Base:
Code: Select all
Select
CURRENT_TIMESTAMP as "Current_TimeStamp",
DATEDIFF('hour', CURRENT_TIMESTAMP, CAST('2012-02-10 13:05:00' as TIMESTAMP) ) as "DateDiff hour",
DATEDIFF('hh', CURRENT_TIMESTAMP, CAST('2012-02-10 13:05:00' as TIMESTAMP) ) as "DateDiff hh",
DATEDIFF('minute', CURRENT_TIMESTAMP, CAST('2012-02-10 13:05:00' as TIMESTAMP) ) as "DateDiff minute",
DATEDIFF('mi', CURRENT_TIMESTAMP, CAST('2012-02-10 13:05:00' as TIMESTAMP) ) as "DateDiff mi"
From INFORMATION_SCHEMA.SYSTEM_TABLES
Where TABLE_TYPE = 'TABLE'
Or, if you have two fields defined as only TIME, use the following SQL, and, change "MyTimeField1" and "MyTimeField2" to the correct names in your table:
Code: Select all
Select
CURRENT_DATE as "Current_Date",
DATEDIFF('hh', CAST(CURRENT_DATE || ' ' || "MyTimeField1" as TIMESTAMP), CAST(CURRENT_DATE || ' ' || "MyTimeField2" as TIMESTAMP)) as "DateDiff hh",
DATEDIFF('hour', CAST(CURRENT_DATE || ' ' || "MyTimeField1" as TIMESTAMP), CAST(CURRENT_DATE || ' ' || "MyTimeField2" as TIMESTAMP)) as "DateDiff hour",
DATEDIFF('mi', CAST(CURRENT_DATE || ' ' || "MyTimeField1" as TIMESTAMP), CAST(CURRENT_DATE || ' ' || "MyTimeField2" as TIMESTAMP))) as "DateDiff mi",
DATEDIFF('minute', CAST(CURRENT_DATE || ' ' || "MyTimeField1" as TIMESTAMP), CAST(CURRENT_DATE || ' ' || "MyTimeField2" as TIMESTAMP))) as "DateDiff minute"
From INFORMATION_SCHEMA.SYSTEM_TABLES
Where TABLE_NAME = 'TABLES'
Eplanation: In the above, using the DATEDIFF function, using different first parameters for demonstration, I am using the CAST function . . .
CAST('2012-02-10 13:05:00' as TIMESTAMP) . . . to change a
text string into a TIMESTAMP. Easy, when you know how.
I hope this helps, please be sure to let me / us know.
Sliderule
Thanks to add
[Solved] in your
1st post Subject (edit button top right) if this issue has been resolved.