[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2008-10-06
3
Medium Priority
?
1,351 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 1000 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 1000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

650 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