Solved

VBScript - Subtracting two Times and Outputing # Minutes

Posted on 2000-03-14
4
860 Views
Last Modified: 2012-06-27
I need a function to subtract two date and times to come up with the number of minutes.  I am new to vbscript how can this be done?
0
Comment
Question by:ubsjmg
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
ndb earned 100 total points
ID: 2616340
Result = DateDiff(DateTime1, DateTime2, "m")
0
 
LVL 3

Expert Comment

by:ivanc
ID: 2616355
ubsima
Convert all the date parameters to integers and substract like integers to make comparisons

Dim Release as Date

toDay = CInt(Format(Now, "dd"))
thsMth = CInt(Format(Now, "mm"))
thsYr = CInt(Format(Now, "yyyy"))
RelDay = CInt(Format(Release, "dd"))
RelMth = CInt(Format(Release, "mm"))
RelYr = CInt(Format(Release, "yyyy"))

Diffyr = Relyr - thsyr
Diffmth = RelMth - thsMth
DiffDay = RelDay - toDay

Hope this helps
Ivan
0
 
LVL 2

Expert Comment

by:damienm
ID: 2616406
ndb I think you have the function the wrong way around

This function should work

MsgBox DateDiff("n", Date1, Date2)
'n is minutes

e.g

Private Sub Command1_Click()
MsgBox DateDiff("n", "1-Jan-00 1 am", "2-Jan-00 2 am")
End Sub

will give msgbox 2500
0
 
LVL 1

Expert Comment

by:ndb
ID: 2616449
Oops ... indeed ... thanx damien.
After all that VB code today I can c them flying ;0)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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