Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Convert time to 24 hour format using VBScript

Posted on 2011-10-19
5
Medium Priority
?
5,898 Views
Last Modified: 2012-05-12
I am having trouble converting this VBScript to output 24 hour time. Can anyone provide a solution for me on what code changes need to take place to make this work?



Thanks,
Dave
Dim strDateTime : strDateTime = DateAdd("n", 1, Now())
Dim strDate     : strDate = LEFT(strDateTime, InStr(strDateTime, " ")-1)
Dim strTime     : strTime = MID(strDateTime, InStr(strDateTime, " ")+1)

wscript.echo strDatetime

Open in new window

0
Comment
Question by:hpops
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:jorgedeoliveiraborges
ID: 36996251
msgbox FormatDateTime (Now)
msgbox FormatDateTime (Now, 0)
msgbox FormatDateTime (Now, 1)
msgbox FormatDateTime (Now, 2)
msgbox FormatDateTime (Now, 3)
msgbox FormatDateTime (Now, 4)

Open in new window

0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 36997009
Try this.

Regards,

Rob.
Dim strDateTime, strDate, strTime
strDateTime = DateAdd("n", 1, Now())
strDate = Left(strDateTime, InStr(strDateTime, " ")-1)
strTime = FormatDateTime(strDateTime, 4)

strDateTime = strDate & " " & strTime

WScript.Echo strDatetime 

Open in new window

0
 

Author Closing Comment

by:hpops
ID: 36997048
Thanks Rob,

This code works perfectly in my script. If I could reward you more points, I would.

Dave
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 36997229
No problem. Thanks for the grade.

Rob.
0
 
LVL 6

Expert Comment

by:jorgedeoliveiraborges
ID: 36999721
WScript.Echo FormatDateTime (Now, 0)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question