Time Formatting - Obtaining the Meridian

  • Thread starter Thread starter MichaelJohnson168
  • Start date Start date
M

MichaelJohnson168

I am needing to extract the meridian (ex. AM or PM) from time.

Is there a way to do this? If so could someone please fill me in. Code
sample is below. I have managed to extract the hour and minute.
However I need to also extract the meridian. Thanks.


day_total_hours = Format((ShopOpensAt), "hh:nn")

hours = Hour(day_total_hours)

minutes = Minute(day_total_hours)
 
Excel tracks time as a fraction of a day in decimal form. So if time less
than .5 then Meridian =AM, else Meridian = PM.

Mike F
 
Assuming you have the time in a variable named 'T', you can use something
like:

If Hour(T) >= 12 Then
Debug.Print "PM"
Else
Debug.Print "AM"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
I am needing to extract the meridian (ex. AM or PM) from time.
Is there a way to do this? If so could someone please fill me in. Code
sample is below. I have managed to extract the hour and minute.
However I need to also extract the meridian. Thanks.

day_total_hours = Format((ShopOpensAt), "hh:nn")

hours = Hour(day_total_hours)

minutes = Minute(day_total_hours)

Meridian = Format(ShopOpensAt,"AMPM")

Rick
 

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

Back
Top