Bre-x said:
How to you convert a date to a integer?
Example
6/14/2006 1:57:37 PM to 1150308000
Actually, you can do this with a date, but NOT a date + time
The above is NOT a date, but a date + time!!!!
Remember, in ms-access, you return the current date with the date()
function.
If you want date + time, then you use "now()" function.
So, you can NOT convert the above time + date into a integer value. The
reason why this is so is because access internal dates are integers, but
the time portion is actually fraction part! That fraction part is of course
24 hours. So, in fact, internal dates are double floating numbers.
So, eg: today is
6/15/2006
? clng(date())
38883
(note that we have to use a long integer, since the value is > 32000)
However, lets convert a full date + time to a double value (with the
fraction part)
? cdbl(#06/15/2006 12:00:00#)
38883.5
Note how the time part is a fractional part. So, with 1/2 day, you get .5
I suspect you considered the
possibly that ms-access uses the SAME internal format as what Unix has
(the UNIX time format is full integer, and is defined as the number of
seconds from Jan 1st, 1970).
So, perhaps you need to be able to convert from UNIX time format to
ms-access time format?
Or, perhaps you want to convent a ms-access time/date value to a UNIX
integer
time value?
The UNIX date/time is the number of seconds from
Jan 01, 1970.
So, we should be able to simply add seconds to this date.
ms-access is full of functions, and we just need to add seconds from that
date till today!!
? datediff("s",#01/01/1970#, #06/15/2006#)
1150329600
? datediff("s",#01/01/1970#, #06/15/2006 00:00:01#)
1150329601
In your case, we go
? datediff("s",#01/01/1970#, #06/14/2006 1:57:37 PM#)
1150293457
The above seems to return a different value then what you posted. (so,
either you number is wrong, or my starting date for UNIX is wrong).
So, you can well convert a ms-access date into a integer value that
represents a UNIX date (which I believe mysql uses).
So, you can't represent a ms-access date + time as a integer in
ms-access. However, you an most certainly convert it to a double precision
value. And, you most certainly can convert the value to what UNIX uses
(number of seconds from 1970).