Am/pm

accessman2

Registered User.
Local time
Today, 10:07
Joined
Sep 15, 2005
Messages
335
Hi,

I have a question.

d = now
Month(d)
Day(d)
Year(d)
Hour(d)
Minute(d)
Second(d)

I know that right(d,2) can retrieve the last 2 chars, AM/PM
However, do we have a function to retrieve AM/PM value?

Thanks.
 
No. The time is PM if after 12 noon. AM if after 12 midnight. The Format() function will allow you to piece is all together with a valid date and time. Search the Access help files for more info. What Accessboy actually use a search function!?!?!
 
one solution for this is ....

Hi man,

you could use this function and get returned if its am or pm

Function ampm() as boolean
Dim stat as string

If Time() < 0.5 Then
stat = "Am"

ElseIf Time() > 0.5 Then
stat = "Pm"
End If
ampm = stat

End Sub

Hope it works for you....:D
 
Format(Now(), "AMPM")


From Access' help file:-

User-Defined Date/Time Formats (Format Function)

AMPM

Use the 12-hour clock and display the AM string literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. The default format is AM/PM.

^
 

Users who are viewing this thread

Back
Top Bottom