🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #358

Re: DateTime in SQL

#358
From: AW
Date: Mon, 28 Aug 2006 07:44
79 lines
3673 bytes
Thank you for you anwser!

"Mike Collins" <its@TheBottomOfThePost.com> schrieb im Newsbeitrag 
news:44ec4a07$1@newsgroups.borland.com...
> Are you using a MS Access database or not?

Yes, I use it even now, but I will support oter databases later.

> If you are then the enclosing characters (#) will be necessary, if your 
> using a SQL setup then there not. Also, i've had major headaches with data 
> / time in MS Access - this may be the same issue that you are 
> experiencing.
>
> What I found is that if you do not explicitly define, within MS Access the 
> format for the date, it can change from what system to another depending 
> on the users settings - for some unknown reason! This also has an impact 
> on the format of that date / time that you provide in your SQL statement. 
> You would assume that some conversion would occur at some point but it 
> doesn't seem to in Access.

Good idea to define the format.

>
> For example, if you look at your database and the date / time is stored as 
> YY-MM-DD HH:NN:SS and you issue an SQL command with the date / time as you 
> have (#2004/01/01 14:55:09#) - it may well fail, event though it works 
> fine in the MS Access IDE / SQL Builder (some conversion must go on here). 
> Even if you were to ensure that the date / time in your SQL statement 
> matched, when you deployed your application, the target user may have a 
> different date format which would then cause the same problem again.
>
> The only consistent way that I found to over come this problem is to 
> specify an Format / Mask for each DateTime field within MS Access.  Then 
> within your application, use the FormatDateTime function to ensure that 
> you always 'deliver', in you SQL, the date in that exact format.

I found an other solution:
In my program the user must not enter the datetime in a SQL-string but a 
special dialog
so I can make conversion to a double.
The internal DateTime storage in Access seem to have the same format as the 
TDateTime in borland.

TDateTime dt;
dt=  ....
double x=dt;     // number for SQL

e.g.        "DateTime = 3334.344533

This works only in Access of course.

Maybe the mask definiton is better ot make different databases compatible.

Bye Andreas



>
> HTH
>
> Mike
>
> "AW" <weichert@trios.de> wrote in message 
> news:44eacbac@newsgroups.borland.com...
>> Hello !
>>
>> I want to insert a DateTime criteria as a filter in a ADODataSet.
>>
>> This example works direct in MSAccess correct but not in a ADODataSet
>> select IDData from tbldata where DateTime = #2004/01/01 14:55:09#
>>
>> How to format the DateTime ?
>>
>>
>> Thanks
>> Andreas
>>
>
> 
Technical Details
Message-ID: <44f29eff@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44eacbac@newsgroups.borland.com> <44ec4a07$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,54e6184ef04cc148
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "AW" <weichert@trios.de>
From: "AW" <weichert@trios.de>
Newsgroups: borland.public.cppbuilder.database.ado
References: <44eacbac@newsgroups.borland.com> <44ec4a07$1@newsgroups.borland.com>
Subject: Re: DateTime in SQL
Date: Mon, 28 Aug 2006 09:44:50 +0200
Lines: 81
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962
NNTP-Posting-Host: 84.129.226.37
Message-ID: <44f29eff@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1156751103 84.129.226.37 (28 Aug 2006 00:45:03 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail