Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time format that omits AM/PM

Status
Not open for further replies.

projecttoday

Programmer
Feb 28, 2004
208
US
I have a Date/time field that contains a value like 5:00 PM. For space problems on a report, it want to print it as "5:00" omitting the PM. I also need to concatenate it to another field so Format(field,"h:mm ampm") and making the textbox short enough so the pm doesn't show really doesn't do what I want. If I use Format(field,"h:mm") 5:00 PM shows as 17:00. If there any way to format a time so it shows the time without am or pm but shows the 12-hour value, not the 24-hour value?
 



Hi,

What? 5:00 is not 5PM! Your request is like wanting 4 to be displayed as 2. How will anyone know exactly what 5:00 REALLY means? AM or PM???

But if you insist on this insanity, convert the time to string, using the Format function and then strip the two right characters.


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 

Code:
    MsgBox Left(Format(TimeSerial(17, 0, 0), "hh:mm AM/PM"), Len(Format(TimeSerial(17, 0, 0), "hh:mm AM/PM")) - 3)


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 



just out of curiosity, when you stated, "I also need to concatenate it to another field ..." exactly what value are you displaying along with time?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 


"Another" date? Where is the FIRST date?

Please post the entire string that you're putting in this area on the report.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 



I'm trying to better understand what you are doing, in order to perhaps, make other suggestions. But you seem to not really understand what I am trying to do. If you wish to be difficult, have it your way.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top