Solved

Help with custom vbscript - Get Time and Increment Time by 30

Posted on 2008-10-06
3
1,342 Views
Last Modified: 2012-06-27
Hello,

Can someone help with a custom vbs that:
1) Gets local time HH:MM format either via vbscript method, wmi or CMD (time /t)
2) Then increment it by 30 minutes and stores it in a variable.? in same format HH:MM
0
Comment
Question by:WinPE
3 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 250 total points
ID: 22654283
This should do it.

dtmTime = DateAdd("n", 30, Time)

strNewTime = Right("0" & Hour(dtmTime), 2) & ":" & Right("0" & Minute(dtmTime), 2)

Open in new window

0
 
LVL 10

Assisted Solution

by:c0ldfyr3
c0ldfyr3 earned 250 total points
ID: 22654670
Try this custom function from http://classicasp.aspfaq.com/date-time-routines-manipulation/can-i-make-vbscript-format-dates-for-me.html

Function Format(vExpression, sFormat) 

 

        set fmt = CreateObject("MSSTDFMT.StdDataFormat") 

        fmt.Format = sFormat 

 

        set rs = CreateObject("ADODB.Recordset") 

        rs.Fields.Append "fldExpression", 12 ' adVariant 

 

        rs.Open 

        rs.AddNew 

 

        set rs("fldExpression").DataFormat = fmt 

        rs("fldExpression").Value = vExpression 

 

        Format = rs("fldExpression").Value 

 

        rs.close: Set rs = Nothing: Set fmt = Nothing 

 

End Function 
 

Dim dTime
 

dTime = Format(CStr(DateAdd("n", 30, Time())),"hh:MM")
 

msgbox dTime

Open in new window

0
 

Author Closing Comment

by:WinPE
ID: 31503603
I liked both methods, thanks alot guys!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now