Date Algorithm

G

Guest

I have the Month, Day and Year in 3 separate fields and now need to
concatenate the 3 fields into one field (Date). What is the algorithm to get
the number Microsoft uses to store a date?
 
R

Rick Brandt

JimN said:
I have the Month, Day and Year in 3 separate fields and now need to
concatenate the 3 fields into one field (Date). What is the algorithm to get
the number Microsoft uses to store a date?

Just use ...

DateSerial(YearField, MonthField, DayField)

Internally Access stores dates a Double Number types. The integer portion is
the count of days since 12-30-1899 and the fractional portion is the time as a
percentage of hours (noon = .5)
 
D

David F Cox

Do you mean the one that they use in Datevale() ?

DateValue Function... Syntax ... DateValue(date)

The required date argument... is normally a string expression ( ... a
string literal, constant, variable, or Variant.) representing a date from
January 1, 100 through December 31, 9999. :
 
J

John Vinson

I have the Month, Day and Year in 3 separate fields and now need to
concatenate the 3 fields into one field (Date). What is the algorithm to get
the number Microsoft uses to store a date?

DateSerial([Year], [Month], [Day])

Note that your three fieldnames are reserved words and BAD choices for
fieldnames; I'd suggest either changing them or always enclosing them
in square brackets.

John W. Vinson[MVP]
 
J

JK

And ...
If you get a Mismatch error on Rick's solution change it to:

DateSerial(Cint(YearField), Cint(MonthField), Cint(DayField))

Regards/JK
 

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

Similar Threads


Top