Thread View: borland.public.cppbuilder.database.ado
3 messages
3 total messages
Started by AW
Tue, 22 Aug 2006 09:17
DateTime in SQL
Author: AW
Date: Tue, 22 Aug 2006 09:17
Date: Tue, 22 Aug 2006 09:17
12 lines
1174 bytes
1174 bytes
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
Re: DateTime in SQL
Author: Mike Collins
Date: Wed, 23 Aug 2006 12:28
Date: Wed, 23 Aug 2006 12:28
44 lines
2813 bytes
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 >
Re: DateTime in SQL
Author: AW
Date: Mon, 28 Aug 2006 07:44
Date: Mon, 28 Aug 2006 07:44
79 lines
3673 bytes
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 >> > >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads