Re: retrieving time using Format()
- From: "Rick Rothstein" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 30 Aug 2008 04:41:34 -0400
In regular expressions, characters in a pattern string that represent something else (like the "h" in the format's pattern string means the hour from a time value) are called meta-characters, so that is the term I'll use here. The general rule about whether the 'm' meta-character is interpreted as 'minute' instead of 'month' appears to be this... if the meta-character immediately preceding an 'm' is an 'h', that is, there are no other time associated meta-characters between the 'h' and the 'm', with the 'h' coming first, then the 'm' is a 'minute' meta-character; in all other situations, the 'm' is a 'month' meta-character. So, in this...
Format(Now, "h m")
the 'm' is a 'minute' meta-character whereas in this..
Format(Now, "h d m")
or this...
Format(Now, "m h")
the 'm' is a 'month' meta-character. If the 'h' precedes the 'm' and there are only non-meta-characters between them, then the 'm' is still a 'minute' meta-character. For example...
Format(Now, "h xrv m")
--
MVP - VB
"Lorin" <Lorin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:29982819-35D4-47F3-BC72-564638DA746D@xxxxxxxxxxxxxxxx
And to add confusion to the mix.
Try this
Debug.Print Format$(Now, "hh:mm:ss ampm")
VB knows in this situation that mm is minutes.
Fun!
Debug.Print Format$(Now, "nn") ' just the minutes
"Jack" wrote:
This works:
Format(Time, "h")
Format(Time, "ss")
Format(Time, "AMPM")
but this does not:
Format(Time, "m") --->returns always 12
or
Format(Time, "mm")--->returns always 12
I know I can use Hour(Time), Minute(Time) etc but that is not I want.
Why is that difference?
Jack
.
- References:
- retrieving time using Format()
- From: Jack
- retrieving time using Format()
- Prev by Date: Re: retrieving time using Format()
- Next by Date: Re: Intellisense
- Previous by thread: Re: retrieving time using Format()
- Index(es):