VBScript - Subtracting two Times and Outputing # Minutes

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?
ubsjmgAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ndbConnect With a Mentor Commented:
Result = DateDiff(DateTime1, DateTime2, "m")
0
 
ivancCommented:
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
 
damienmCommented:
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
 
ndbCommented:
Oops ... indeed ... thanx damien.
After all that VB code today I can c them flying ;0)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.