Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Include AM or PM using DatePart Function

Reply
 
Old 01-15-2009   #1 (permalink)
Len


 
 

Include AM or PM using DatePart Function

I do not know how to extract the AM or PM in the DatePart Function

My Code is:

<%
tmCurrentTime = Now()
tmCurrentTime = DatePart("h",tmCurrentTime) & ":" &
DatePart("n",tmCurrentTime)
%>

This works, but I do not know how to get the AM or PM.

If DatePart("h",tmCurrentTime) is 4, how do I know if it is AM or PM?

Thanks for the help.

Len


My System SpecsSystem Spec
Old 01-15-2009   #2 (permalink)
James Whitlow


 
 

Re: Include AM or PM using DatePart Function

"Len" <Len@xxxxxx> wrote in message
newsF5AE6E6-CB72-451F-A6BF-EE57A8C0B34B@xxxxxx
Quote:

>I do not know how to extract the AM or PM in the DatePart Function
>
> My Code is:
>
> <%
> tmCurrentTime = Now()
> tmCurrentTime = DatePart("h",tmCurrentTime) & ":" &
> DatePart("n",tmCurrentTime)
> %>
>
> This works, but I do not know how to get the AM or PM.
>
> If DatePart("h",tmCurrentTime) is 4, how do I know if it is AM or PM?
It should return the hour of the day starting from midnight. In your
example above, it should return '4' for 4 AM and '16' for 4 PM.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Script that uses the DatePart & Case select VB Script
How to reverse DatePart("y",Date) ? VB Script
Week number with DatePart syntax, and Server... VB Script
BUG: Redirecting function contents to a file truncates function lines at the width of the console PowerShell
Tab Completion customization to include function search? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46