Subject RE: [firebird-support] date functions
Author Helen Borrie
At 01:20 PM 5/12/2003 +0200, you wrote:
>OK what we have to do is automatically raise (billing) transactions for all
>days between last billed transaction and the day that the process fires.
>What we have is: Today (excluding time portion or defaulting to 00:00:00),
>The date in for the billing, and the date out for the billing. We must
>establish if the date out is earlier than start of day tomorrow (end of day
>today) then a new transaction must be created with a date in of start of day
>FOR THAT DAY's tomorrow and date out for start of day the following day. In
>Delphi trunc - ing the dates works just fine but this must take place in a
>If I could get just the date portion of the datetime then I could (as you
>know) just add integer values to increment the days. If there is another
>way to achieve this, I'm all ears :-)

Indeed there is. If you do
cast (any_timestamp as date) you get a date-only value. Then do
cast(that_date as timestamp) and you get the date + 00:00:00.0000.

You can also do
cast(any_timestamp as time) to get and hold the time-of-day from the
datestamp, if you need to perform some calculation when the day rolls over.