Article View: borland.public.interbase.sql
Article #1034Re: Round a DateTime
From: Laurence
Date: Mon, 19 Mar 2007 12:29
Date: Mon, 19 Mar 2007 12:29
33 lines
2232 bytes
2232 bytes
On 19 Mar, 04:31, Robin <Robin@.com> wrote: > 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/ If you want to count only days have you thought of using the EXTRACT function ?
Technical Details
Message-ID:
<1174307364.095064.74440@d57g2000hsg.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!d57g2000hsg.googlegroups.com!not-for-mailReferences:
<45fe1225@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 Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!d57g2000hsg.googlegroups.com!not-for-mail From: "Laurence" <LaurenceAsquith@chainreactioncycles.com> Newsgroups: borland.public.interbase.sql Subject: Re: Round a DateTime Date: 19 Mar 2007 05:29:24 -0700 Organization: http://groups.google.com Lines: 34 Message-ID: <1174307364.095064.74440@d57g2000hsg.googlegroups.com> References: <45fe1225@newsgroups.borland.com> NNTP-Posting-Host: 217.37.34.253 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1174307365 29550 127.0.0.1 (19 Mar 2007 12:29:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 19 Mar 2007 12:29:25 +0000 (UTC) In-Reply-To: <45fe1225@newsgroups.borland.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: d57g2000hsg.googlegroups.com; posting-host=217.37.34.253; posting-account=uQhp_Q0AAADRh1Ij7xy8INjEx0YHcrdu