Entering date and time seperately

M

mscertified

I'm writing a calendar application. The users want to be able to enter dates
and times in separate controls. How do I do this? I understand a datetime
column contains both. Can a datetime column contain just a time with no date?
And can a datetime column contain just a date with no time?
 
D

Douglas J. Steele

The Date data type in VBA is an eight byte floating point number where the
integer portion represents the date as the number of days relative to 30
Dec, 1899, and the decimal portion represents the time as a fraction of a
day. Yes, it's possible to store just a time in there, but recognize that as
far as Access is concerned, you've entered a time on 30 Dec, 1899.

Just because your users want to enter dates and times as separate values
doesn't mean you have to store them that way! If you've got a date value and
a time value, you can simply add them together to result in a timestamp. If
you've got a timestamp and you want only the date portion, you can use the
DateValue function. If you've got a timestamp and you want only the time
portion, you can use the TimeValue function.
 

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