ODBC question
Joao Vargem -- jpv.loyaltech@taguspark.pt
Monday, March 17, 1997
Environment: Windows 95, MSVC++ 4.1
Hi all. I have a question I hope someone may help me with.
How can I determine the date format the ODBC driver recognizes?
It's always been a pain working with dates but this time I'm getting
really frustraded. I display the
dates in the application accordingly to the format in the control panel,
but I must give them to the driver in the format it accepts. The driver
I'm using accepts 'yyyy-mm-dd', and to keep working I have this format
hardcoded and make the conversion. My problem is if other drivers use
other formats. I can't find a way to check what format to use. Any help
is welcome.
--
Joao Vargem (jpv.loyaltech@taguspark.pt)
LoyalTech Portugal SA
Oeiras, Portugal
Tim Meyer -- tmeyer@southeast.net
Wednesday, March 19, 1997
[Mini-digest: 6 responses]
If this is a 32-bit OBDC driver, try using the ODBCINFO program that comes
as a
sample with VC++ 4.2. It uses a lot of the SQL native commands to display
all the
capabilities of the driver. Date might be one.
----------
> From: Joao Vargem
> To: MFC Mailing List
> Subject: ODBC question
> Date: Monday, March 17, 1997 12:53 PM
>
> Environment: Windows 95, MSVC++ 4.1
>
> Hi all. I have a question I hope someone may help me with.
>
> How can I determine the date format the ODBC driver recognizes?
>
> It's always been a pain working with dates but this time I'm getting
> really frustraded. I display the
> dates in the application accordingly to the format in the control panel,
> but I must give them to the driver in the format it accepts. The driver
> I'm using accepts 'yyyy-mm-dd', and to keep working I have this format
> hardcoded and make the conversion. My problem is if other drivers use
> other formats. I can't find a way to check what format to use. Any help
> is welcome.
>
> --
> Joao Vargem (jpv.loyaltech@taguspark.pt)
> LoyalTech Portugal SA
> Oeiras, Portugal
-----From: "Tim O'Neil"
At 09:53 AM 3/17/97 -0800, you wrote:
>Environment: Windows 95, MSVC++ 4.1
>
> Hi all. I have a question I hope someone may help me with.
>
> How can I determine the date format the ODBC driver recognizes?
>
>It's always been a pain working with dates but this time I'm getting
>really frustraded. I display the
>dates in the application accordingly to the format in the control panel,
>but I must give them to the driver in the format it accepts. The driver
>I'm using accepts 'yyyy-mm-dd', and to keep working I have this format
>hardcoded and make the conversion. My problem is if other drivers use
>other formats. I can't find a way to check what format to use. Any help
>is welcome.
I get this question alot. If you put any dates you are working with in
an escape clause, you should get the cross-platform functionality you are
looking for. {d 'value'} for dates, {t 'value'} for times, and {ts 'vlaue'}
for timestamps. Say you want to update a date column;
update mytble set mydate {d '1997-3-19'} where myname = 'Smith, John'
See the Microsoft ODBC SDK Reference Guide for the full skinny.
=====================================================
Tim O'Neil toneil@visigenic.com
Technical Support Engineer support@visigenic.com
Visigenic Software, Inc. http://www.visigenic.com
=====================================================
-----From: "Frank McGeough"
There are a set of ODBC standard escape sequences defined
for date, time and timestamp.
// ODBC escape for date : {d 'yyyy-mm-dd'}
// for time : {t 'hh:mm:ss'}
// for timestamp : {ts 'yyyy-mm-dd hh:mm:ss[.f...]'}
Check Appendix A of the ODBC SDK Guide. Alternatively bind as
a parameter where you can use the standard structures.
----------
> From: Joao Vargem
> To: MFC Mailing List
> Subject: ODBC question
> Date: Monday, March 17, 1997 12:53 PM
>
> Environment: Windows 95, MSVC++ 4.1
>
> Hi all. I have a question I hope someone may help me with.
>
> How can I determine the date format the ODBC driver recognizes?
>
> It's always been a pain working with dates but this time I'm getting
> really frustraded. I display the
> dates in the application accordingly to the format in the control panel,
> but I must give them to the driver in the format it accepts. The driver
> I'm using accepts 'yyyy-mm-dd', and to keep working I have this format
> hardcoded and make the conversion. My problem is if other drivers use
> other formats. I can't find a way to check what format to use. Any help
> is welcome.
>
> --
> Joao Vargem (jpv.loyaltech@taguspark.pt)
> LoyalTech Portugal SA
> Oeiras, Portugal
-----From: "Manny Powers"
> Hi all. I have a question I hope someone may help me with.
>
> How can I determine the date format the ODBC driver recognizes?
All ODBC Drivers have to recognize "{d 'yyyy-mm-dd'}" as the date format.
HTH,
Manny
-----From: "Dan Kirby"
One way to handle this is to use the ODBC SQL Extensions (also called
escape clauses) talked about in Chp.6 of the ODBC 2.1 Programmer's
reference in the books online. Essentially you'll use {d 'yyyy-mm-dd'} or
the extended form of that. See the programmer's reference for more
information.
>From the ODBC Programmer's Reference:
To determine if a data source supports date, time, or timestamp data, an
application calls SQLGetTypeInfo. If a driver supports date, time, or
timestamp data, it must also support the escape clauses for date, time, or
timestamp literals.
--dan
----------
> From: Joao Vargem
> To: MFC Mailing List
> Subject: ODBC question
> Date: Monday, March 17, 1997 9:53 AM
>
> Environment: Windows 95, MSVC++ 4.1
>
> Hi all. I have a question I hope someone may help me with.
>
> How can I determine the date format the ODBC driver recognizes?
>
> It's always been a pain working with dates but this time I'm getting
> really frustraded. I display the
> dates in the application accordingly to the format in the control panel,
> but I must give them to the driver in the format it accepts. The driver
> I'm using accepts 'yyyy-mm-dd', and to keep working I have this format
> hardcoded and make the conversion. My problem is if other drivers use
> other formats. I can't find a way to check what format to use. Any help
> is welcome.
>
> --
> Joao Vargem (jpv.loyaltech@taguspark.pt)
> LoyalTech Portugal SA
> Oeiras, Portugal
-----From: jtalkar@optika.com (Jeremiah Talkar)
Hi! I have found the MFC ColeDateTime member functions "Format" and
ParseDateTime" invaluable for all kinds of date-time conversions etc.
Since you are using VC++ 4.1, you may not be able to use them as these
were available with VC++ 4.2 Patch.
Jeremiah
-----Original Message-----
From: Joao Vargem
Sent: Monday, March 17, 1997 9:53 AM
To: MFC Mailing List
Subject: ODBC question
Environment: Windows 95, MSVC++ 4.1
Hi all. I have a question I hope someone may help me with.
How can I determine the date format the ODBC driver recognizes?
It's always been a pain working with dates but this time I'm getting
really frustraded. I display the
dates in the application accordingly to the format in the control panel,
but I must give them to the driver in the format it accepts. The driver
I'm using accepts 'yyyy-mm-dd', and to keep working I have this format
hardcoded and make the conversion. My problem is if other drivers use
other formats. I can't find a way to check what format to use. Any help
is welcome.
--
Joao Vargem (jpv.loyaltech@taguspark.pt)
LoyalTech Portugal SA
Oeiras, Portugal
Become an MFC-L member
| Вернуться в корень Архива
|