Leading zero in time

G

Guest

I would like to format a date/time field, such that, the time component is
displayed in 24 hours format. How do I ensure a leading zero is added to time
from 00:00 to 09:59?

For example, a leading zero is added to time 07:30.
 
G

Guest

If component is a field in a table the set the Format property of the field
to General Date or Short Time and the zero is automatically added. If the
component is a field on a form then in t the afterUpdate event add the code
FieldName = Format(FieldName,"General Date") or Short Time or Medium Time or
whichever format you want
 
M

Marshall Barton

Charles said:
I would like to format a date/time field, such that, the time component is
displayed in 24 hours format. How do I ensure a leading zero is added to time
from 00:00 to 09:59?

For example, a leading zero is added to time 07:30.


What have you tried?

Doesn't setting the text box's Format property to:
mm/dd/yy hh:nn
do what you want?
 
G

Guest

In the text box format property, I set "d mmm yy, hh:nn", but the hour
leading zero still doesn't show up. For example, it shows "2 Oct 04, 1:00"
instead of "2 Oct 04, 01:00". Do you know how to fix it?
 
M

Marshall Barton

Interesting! I set a text box's Format property to:
d mmm yyyy hh:nn
and it left out the 0 as you said.

I then tried using another text box with the expression:
=Format(textbox1, "d mmm yyyy hh:nn")
and the 0 was included.

Exact same format string, but different results!??

If/how you can utilize that information, depends on your
specific situation.
 

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