Article View: borland.public.interbase.sql
Article #11265Re: Variant types for Interbase data types
From: Wayne Niddery [TeamB]
Date: Mon, 02 Dec 2002 00:09
Date: Mon, 02 Dec 2002 00:09
33 lines
2796 bytes
2796 bytes
"Edward Diener" <eddielee@tropicsoft.com> wrote in message
news:3dea8b03$1@newsgroups.borland.com...
>
> That's not the question. The question is: how do I convert DATE, TIME, and
> TIMESTAMP variant values to values I can use in an SQL statement. Does SQL
> using these types accept a 32 bit integer number, a 32 bit integer number,
> or a 64 bit integer number respectively for each of these values, or do
> these values have to be in some sort of string format, ie. for DATE "Dec
> 01,2002", to be accepted. If SQL accepts these values as just integer
> numbers, then everything is fine, but if SQL needs some sort of string
> values, then I have to convert them to some sort of acceptable string
> format.
Interbase accepts them as strings in standard formats, or as parameters. You
are *much* better off using parameters wherever possible. You are also much
better off avoiding variants wherever possible, especially with regard to
dates and times. For dates and times, use the Delphi TDateTime type if you
can. If you want to format a date into SQL, you can use the FormatDateTime
function (avoid DateToStr, et al as these convert according to the local
Windows settings which may or may not be acceptable formats for Interbase).
Using parameters is simple:
Query1.SQL.Text := 'select * from table where datefield = :datefield';
Query1.ParamByName('datefield').AsDateTime := MyTDateTimeVar;
// or... Query1.Params[0].AsDateTime := MyTDateTimeVar;
--
Wayne Niddery (Logic Fundamentals, Inc.)
RADBooks: http://www.logicfundamentals.com/RADBooks/delphibooks.html
It used to be that other people's achievements were considered an
inspiration, not a grievance.
Technical Details
Message-ID:
<3deaa556$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mailReferences:
<3dea4ff3$1@newsgroups.borland.com> <s5tkuuklumb7k0o2tdo46fjujjtpf2v998@4ax.com> <3dea8b03$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 114a0e,4b82b358170a5247 X-Google-Attributes: gid114a0e,public X-Google-ArrivalTime: 2002-12-01 16:15:51 PST From: "Wayne Niddery [TeamB]" <wniddery@chaff.aci.on.ca> Newsgroups: borland.public.interbase.sql References: <3dea4ff3$1@newsgroups.borland.com> <s5tkuuklumb7k0o2tdo46fjujjtpf2v998@4ax.com> <3dea8b03$1@newsgroups.borland.com> Subject: Re: Variant types for Interbase data types Date: Sun, 1 Dec 2002 19:09:53 -0500 Lines: 35 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 209.50.82.158 Message-ID: <3deaa556$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1038787926 209.50.82.158 (1 Dec 2002 16:12:06 -0800) X-Authenticated-User: wniddery Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail