🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Round a DateTime

#1032
From: Robin
Date: Mon, 19 Mar 2007 04:31
29 lines
1762 bytes
Hi everyone,

I want to count distinct days in a period from a datetime field.  I am 
surprised by how difficult I have found this.

My problem is in getting the date part of a datetime in SQL.

Is there a way to truncate a datetime to just a date?

I thought trunc or frac, but they are not available.  I can't seem to 
cast the datetime as an integer either.

The only way I have found is to cast the datetime as varchar(11) which 
happens to return only the date part.  Then cast THAT as an integer.

Which /appears/ to work, but makes me feel dirty ;-)

I am using Interbase6.x/FB1.5.  I am unable to make stored procedures, 
UDF etc so I need to do it in raw SQL only.

Any ideas?

Thanks in advance.

-- 
Robin.

Australian Bridal Accessories := http://www.bridalbuzz.com.au
Turbo for Noobs (a work in progress) := http://turbofornoobs.blogspot.com/
Technical Details
Message-ID: <45fe1225@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feed10.multikabel.net!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,cf698e5e2a79f5a0,start
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 19 Mar 2007 15:31:54 +1100
From: Robin <Robin@.com>
User-Agent: Thunderbird 1.5.0.7 (Windows/20060909)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Round a DateTime
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 165.228.6.111
Message-ID: <45fe1225@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1174278693 165.228.6.111 (18 Mar 2007 21:31:33 -0800)
Lines: 29
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feed10.multikabel.net!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail