SQL data type for Microsoft Access time and date fields

SQL data type for Microsoft Access time and date fields

Post by Dave Brow » Fri, 13 Dec 2002 06:08:41



In Microsoft Access (2000, but this also occurs in 97), I create two fields in a
table of types "short date" and "short time". In some software which queries the
table, I use SQLColumns() and query the result set on column 5 to get the SQL
Data Type. In both cases it returns SQL_TYPE_TIMESTAMP. This is no good. I need
to know whether it is a time or date field. Any ideas?

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----

 
 
 

SQL data type for Microsoft Access time and date fields

Post by Bob Hairgro » Sun, 15 Dec 2002 19:05:44



>In Microsoft Access (2000, but this also occurs in 97), I create two fields in a
>table of types "short date" and "short time". In some software which queries the
>table, I use SQLColumns() and query the result set on column 5 to get the SQL
>Data Type. In both cases it returns SQL_TYPE_TIMESTAMP. This is no good. I need
>to know whether it is a time or date field. Any ideas?

In Access, it is not possible to distinguish between date and time.
Both are treated as timestamps. Access ALWAYS stores a time element
along with the date. Internally, Access uses a double which encodes
the date in the whole number part and the time in the fractional part.
If the date is returned as 0, and the time part is > 0, you know you
are dealing with a time value (I believe 0 would be equivalent to Dec.
31, 1899 ... earlier dates are negative numbers).

If you are querying with ODBC functions, as it seems to be the case,
just bind the column to an SQL_TYPE_TIMESTAMP structure (or retrieve
as character data) and throw away whatever you aren't interested in.

Bob Hairgrove


 
 
 

SQL data type for Microsoft Access time and date fields

Post by Dave Brow » Wed, 18 Dec 2002 21:55:25


Thanks Bob, at least now I understand why it is happening. The problem that I
have a generic piece of software to produce reports from such a database. It
doesn't *know* what types the fields are, so it asks for the column data type
before deciding how to interpret the result. From what you are saying, it would
appear that what I am trying to do is impossible, unless maybe I fudge the
reporting software so that if it detects a timestamp type, AND the source is MS
Access then retrieve the data first as a timestamp, then as a double to figure
out which bit to use. At the moment, I've modified the database so that they are
both straight text fields, but it doesn't make me happy.
Anyway, thanks again.
Dave


>In Access, it is not possible to distinguish between date and time.
>Both are treated as timestamps. Access ALWAYS stores a time element
>along with the date. Internally, Access uses a double which encodes
>the date in the whole number part and the time in the fractional part.
>If the date is returned as 0, and the time part is > 0, you know you
>are dealing with a time value (I believe 0 would be equivalent to Dec.
>31, 1899 ... earlier dates are negative numbers).

>If you are querying with ODBC functions, as it seems to be the case,
>just bind the column to an SQL_TYPE_TIMESTAMP structure (or retrieve
>as character data) and throw away whatever you aren't interested in.

>Bob Hairgrove


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
 
 
 

1. MySQL ODBC - Coverting Access date/time type to MySQL date/time type

All

Has anyone had the following problem with the MySQL ODBC (& hopefully
have a solution!):

When uploading tables from a Access '95 database to a MySQL database the
date/time type in Access become muddled! I have sent the data up in
dd/mm/yy format & yyyy-mm-dd format but the information comes out with
additional digits (e.g., '1998-12-14' comes out as '00:00:00 1998-12-14'
or the time 22:45:10 comes out with nn:nn:nn 22:45:10 (were 'n' is a
digit which depends on the time uploaded!)).

HELP!

Regards

2. dbload problem

3. Problem accessing record from SQL Data base Date/Time Field

4. Scheduled DTS package

5. ADO with Access Date/Time field not storing the time, just the date

6. Pick bitching

7. GROUP BY on a field of data type date/time

8. Remote Network Connection

9. INGRES date data type vs Standard Time/Daylight Savings Time change

10. SQL Server Date/Time Field Type

11. Feature-request: allowing the date/time type to accept ISO8601 compliant date/time combinations on input

12. Correct Syntax for Date/Time data types in SQL statements