Subject date functions
Author Russell Eva
Helen, This is an excerpt from our previous discussion. We subsequently did
as advised below and it appeared to be 100% _UNTIL_ the procedure fires at
00:00 hours and then some records were omitted. On inspection we found the

The following query does not return data as expected

select cast('TODAY' as TimeStamp) today, /* fine */
cast(cast(date_out as date) as TimeStamp) date_out, /* Fine */
cast(cast(date_out as timeStamp)as date) /* expected to display only
date, but still has the hours and minutes with */

from visit_accom_days

Do you have any clues please?


From: Helen Borrie [mailto:helebor@...]
Sent: Friday, December 05, 2003 14:17
Subject: RE: [firebird-support] date functions

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
>FOR THAT DAY's tomorrow and date out for start of day the following day.
>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.


Yahoo! Groups Sponsor


r/ban/syah/default.asp> click here


To unsubscribe from this group, send an email to:

Your use of Yahoo! Groups is subject to the Yahoo!
<> Terms of Service.

[Non-text portions of this message have been removed]