Re: Can I store Date and Time in long integer?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Ralph wrote:

The date values in VB and the two in MS SQL are based on three
different epochs/counts and are not equivalent.

A VB is a decimal:
The integer portion represents the number of whole days since the
epoch. The decimal portion represents the fraction of a day since
midnight of the epoch
It starts from Midnight December 30, 1899.
Negatives can be used for earlier dates, but not all tools will be
able to decypher what you are talking about. <g>

Frankly, I am at a lost of why you would want to store datetime as a
long when you can just as easily store and pass around a decimal?

And the fact that VB / OLE dates are stored in the same form as a double is overkill. If you _really_ need to store a conventional VB date/time in 4 bytes, just use a Single (Dat! = CSng(Now)). As long as you're talking about relatively recent dates, you can get the exact date, and minor (if any) loss of precision for the time.

--

Jim Mack
MicroDexterity Inc
www.microdexterity.com
.