Format Now() to include just time

S

Scott

How do I format the Now() function to record just the time, for example 7:55
AM not 8/10/2004 7:55 AM.

Thanks

Scott
 
J

Jeff Boyce

Scott

The Access Date/Time data type stores, well, date AND time. If you need to
store only a time, use a text field and build parsing routines.

If you need to DISPLAY only a time, look into formatting in Access HELP --
you didn't mention whether you were working in a table design or on a form
(or report).

By the way, the Now() function is "point-in-time", and includes both date
and time. Have you looked into the Time() function? How would you tell the
difference between 7:55 AM yesterday and 7:55 AM today? Or is this not
important to what you are trying to do?
 
K

Kamil Dursun

Any of the following would do:

MyStr = Format(now(), "hh:mm:ss")
MyStr = Format(now(), "Long Time")
MyStr = Format(now(), "Medium Time")

Kamil
 
R

Rick Brandt

Scott said:
How do I format the Now() function to record just the time, for example 7:55
AM not 8/10/2004 7:55 AM.

You can't. The DateTime Data Type always has both a date and a time. When
you enter only a date the time defaults to midnight and when you enter only
a time the date defaults to 12/30/1899.

Access will (by default) display only the time when the date is 12/30/1899
and only the date when the time is midnight which can give the impression
that the non-displayed portion is not being stored, but that is only a
display issue.
 
S

Scott

Thanks for your reply, I have a related table that stores the date, I will
use Time()


Scott
 
T

tina

formatting only affects how data is displayed, it does not affect the data
itself. there is no way to record a time without a date in a table field
with a Date/Time data type. Now() returns the current date and current time
as a value, regardless of how it's formatted.
 
Top