🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #1040

Re: Round a DateTime

#1040
From: Robin
Date: Tue, 20 Mar 2007 01:20
35 lines
1822 bytes
Quinn Wildman (CodeGear Developer Support) wrote:
> However, if you subtract two timestamps you get a number. You can then 
> do math on that. Example:
> 
> select
> 
> select current_timestamp-cast('1/1/0001' as timestamp) from rdb$database;

Hi Quinn,

Thank you!  I took a little while to really see where you were going 
with this, but it did give me a solution!

For future reference, to get a distinct identifier for a day I 
subtracted the date field from "NOW" (you could use any datetime) then 
cast the resulting floating point number as an integer.  The result may 
not be the date itself, but it is a unique identifier for each day which 
is enough for me.

Eg:

SELECT
CAST(MyDateField - "NOW" AS Int)

FROM
MyTable


Thank you, thank you, thank you!

-- 
Robin.

Australian Bridal Accessories := http://www.bridalbuzz.com.au
Turbo for Noobs (a work in progress) := http://turbofornoobs.blogspot.com/
Technical Details
Message-ID: <45ff36d1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45fe1225@newsgroups.borland.com> <45febc5a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,cf698e5e2a79f5a0
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 20 Mar 2007 12:20:38 +1100
From: Robin <Robin@.com>
User-Agent: Thunderbird 1.5.0.7 (Windows/20060909)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Re: Round a DateTime
References: <45fe1225@newsgroups.borland.com> <45febc5a$1@newsgroups.borland.com>
In-Reply-To: <45febc5a$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 165.228.6.111
Message-ID: <45ff36d1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1174353617 165.228.6.111 (19 Mar 2007 18:20:17 -0800)
Lines: 35
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail