converting dates to sequential number

J

JaneCline

I need to convert a date field to the sequential number
the computer assigns to it. What is that function?
 
G

Gerald Stanley

Take a look at the DateSerial function.

Hope This Helps
Gerald Stanley MCSD
 
V

Van T. Dinh

Dates are store like a Double number with the integral part represents the
number of days since 31/Dec/1899. Thus, you can simply use the Format
Property or Format function to get this number.

For example (from the Debug window):

?Format(Date(), "0")
38143

i.e. today 05/Jun/2004 is 38143 days since 31/Dec/1899.
 
S

Steve Schapel

Van,

The reason I prefer CLng() over Format() in this context is because the
result of CLng() is a number where Format() returns a string.
 
V

Van T. Dinh

Hi Steve

Date Field values are numeric under the hood (I think) so I saw no needs to
convert to numeric and interpreted Jane's question as formatting rather than
converting.
 
S

Steve Schapel

Sure, Van, just wanted Jane to be aware of the difference. I admit in
practice it probably wouldn't make a lot of difference unless you are
dealing with dates before 17 May 1927, when we go from 4 digits to 5.

I'm so used to applying CLng() to dates, to cater to the American date
format problem :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top