🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: DateTime in SQL

#354
From: Mike Collins
Date: Wed, 23 Aug 2006 12:28
44 lines
2813 bytes
Are you using a MS Access database or not?  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.

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.

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: <44ec4a07$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.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>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,54e6184ef04cc148
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mike Collins" <its@TheBottomOfThePost.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <44eacbac@newsgroups.borland.com>
Subject: Re: DateTime in SQL
Date: Wed, 23 Aug 2006 13:28:48 +0100
Lines: 46
Organization: SDA Ltd
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.2663
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2757
NNTP-Posting-Host: 81.2.92.14
Message-ID: <44ec4a07$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1156336135 81.2.92.14 (23 Aug 2006 05:28:55 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.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