Wednesday, 21 May 2014

DateDiff Function :-The DateDiff function will calculates the amount of time between two different dates.

Syntax :-
DateDiff(Interval, Date1, Date2, FirstDayofWeek, FirstWeekofYear)

Example:-

S=Datediff("d","01/May/2014","21/May/2014")
msgbox S
Output=20 (return the day different)

S1=Datediff("m","01/Jan/2014","21/May/2014")
msgbox S1
Output=4 (return the Month different)

S2=Datediff("yyyy","01/May/2013","21/May/2014")
msgbox S2
Output=1 (return the Year different)

S3=Datediff("w","01/May/2014","21/May/2014")
msgbox S3
Output=2 (return the week different)

S4=Datediff("y","01/May/2014","21/May/2014")
msgbox S4
Output=20 (return the day different of the year)

S5=Datediff("h","01/May/2014","21/May/2014")
msgbox S5
Output=480 (return the Hours different of the year)

S6=Datediff("n","01/May/2014","21/May/2014")
msgbox S6
Output=28800 (return the Minutes different of the year)

S7=Datediff("s","01/May/2014","21/May/2014")
msgbox S7
Output=1728000 (return the Seconds different of the year)

No comments:

Post a Comment