Subject Re: Time difference between two date columns
Author Adam
--- In firebird-support@yahoogroups.com, Shariful Alam
<murad_mouri@...> wrote:
>
> Hello,
>
> I need time difference between two date columns in
> hour basis. How can I get this in sql statement?

Do you literally mean 'date' fields in dialect 3? If so, they store
the year, month and day only,

Subtracting two of these fields will return you an integer, being the
difference in days. Simply multiply that by 24 to get the number of hours.

eg.

select ((DateFieldEnd - DateFieldStart) * 24) as HoursDifference
from SomeTable

It makes a bit more sense if these fields are actually Timestamp
fields, as they store year, month, day, hour, minute, second. The
syntax is exactly the same, and they return the number of days between
them (although it isn't necessarily a whole number returned, 6 hours
is returned as 0.25 for example).

eg

select ((TimestampFieldEnd - TimestampFieldStart) * 24) as HoursDifference
from SomeTable


Adam