-
October 19th, 2004, 11:16 AM
#1
time formatting
I am formatting a string like so:
.Column("StartTime").Value = Format(clsDateConvert.sShortTime, "hh:mm:ss AMPM")
This works perfectly most of the time, but if the sShortTime value is 24:00, it will not format the value correctly.
i.e.
for "23:00" it will convert to "11:30 PM" properly
but for "24:00" it will remain as "24:00" instead of converting to "12:00 PM"
Why does this happen?
-
October 19th, 2004, 11:30 AM
#2
Re: time formatting
2300 (eleven oclock) gets converted to 1130PM (half past eleven)?
2400 doesnt get converted to 1200PM (why would it? surely 2400 is 12 AM ?)
sounds like the conversion routine is screwed.. any convertor that adds half an hour when converting 2300, ought to be dumped..
-
October 19th, 2004, 12:20 PM
#3
Re: time formatting
2400 doesnt get converted to 1200PM (why would it? surely 2400 is 12 AM ?)
Right, reguardless, it is not converted to 1200AM either. Apparently the Format function does not work properly? Do I need to write my own code to handle this particular case?
thanks
-
October 19th, 2004, 02:08 PM
#4
Re: time formatting
There are only 24 hours in a day. Thus 23:59 is as far as it goes, and 24:00 is an invalid time.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
October 19th, 2004, 02:19 PM
#5
Re: time formatting
Thankyou.
I just learned our system allows 24:00 as a valid time
10.19.04 & 24:00:00
is the same as
10.20.04 at 00:00:00
I'll have to code this special case we use.
-
October 19th, 2004, 04:00 PM
#6
Re: time formatting
Actually, I believe "n" should be used for minutes, as in "hh:nn:ss AMPM", although both do seem to work in a quick test I just tried ("m" is for months). Anyway, the IsDate() function shows "24:00" as invalid, so you should probably use that to prevent formatting errors.
Using the following formula could also help: MyHour = TheHour Mod 24. This would require parsing out the hour, but you cannot use Hour(TheTime) on an invalid time.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|