Hi ,
I have two textboxes to let user key in birthdate & birthtime separately.
The format of birthdate is yyyy/mm/dd and birthtime is AM 10:30 for example.
How can I combine birthdate and birthtime together as Date type? Thank you.
As Access stores the values as numbers (the Format is irrelevant),
just add them together.
The date portion is the count of the number of days passed since
12/30/1899.
The Time portion is the decimal part of a 24 hour period,
So today is stored as 40008.0
The time (let's say it's 6:00 AM exactly) is stored as 0.25 (a quarter
of a 24 hour day).
So 40008.0 + 0.25 equals 40008.25 (or 7/14/2009 06:00:00)
=[BirthDate] + [BirthTime]
If you are storing the above 2 fields, this combined value ought NOT
be stored in a table. Simply recalculate it when needed.
If the 2 separate text boxes are just for the convenience of user
entry, then the table should have just one [DateOfBirth] field, and
you can use the Form's AfterUpdate event to store the combined values
into the one field:
Me.[DateOfBirth] = Me.[BirthDate] + [BirthTime]
You would use the Form's BeforeUpdate event to check whether both text
boxes have been filled (correctly).