Time format hhnn drops leading zero

C

Chuck

In Access 2007 with SP 2, I have a Text Box with a Date/Time Data Type
Control Source. Setting the Format property to "hhnn" or "hnn" both give me
the same results: there is no leading zero on the time part of the displayed
value when the time of day is before noon. Interestingly enough, midnight is
displayed as "000".

Would anyone happen to have a work around for this problem?
 
C

Chuck

The colon is optional when setting the Format property for a Text Box.
Besides, the result is the same with or without a colon. Times before noon
are displayed without the leading zero. The Help file for the Date/Time Data
Type format says:

h Hour in one or two digits, as needed (0 to 23).
hh Hour in two digits (00 to 23).
 
C

Chuck

Sure does. The result you obtained in your first test is exactly what I want.

However, your test uses the VBA Format function. My problem is with the
Format property of a Text Box control. They should produce the same results
(from the same input value), but I'm afraid the operative word here is
"should".

Incidentally, when I said above that "times before noon are displayed
without the leading zero.", I should have said "times before 10:00 am".

The problem appears to me to be that the software functionality doesn't
agree with the documentation of that functionality. The documentation very
clearly says that one h will cause the time to be formatted as 0 to 23 (with
no leading zeroes before 10:00 am) while two h's will cause the time to be
formatted as 00 to 23 (with leading zeroes).

I have checked the Windows Regional and Language Options and the default
values (for Vista) are just fine. Besides, as you said, formatting should
override them. And, in fact, it is overriding the date format option by
formatting the time on a 24 hour basis.
 

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