Friday 25 October 2013

Excel Macro to get the date difference

Sub getDateDiff()
'Excel macro to get the date difference in term of day, week, year

'Suppose you want to find the total number of days between date1 = "09-jan-1987" and date2="12-jan-2012"
date1 = "09-jan-1987"
date2 = "12-jan-2012"
MsgBox "Total days between " & date1 & " and " & date2 & " is -> " & DateDiff("d", date1, date2)
MsgBox "Total weeks between " & date1 & " and " & date2 & " is -> " & DateDiff("ww", date1, date2)
MsgBox "Total years between " & date1 & " and " & date2 & " is -> " & DateDiff("yyyy", date1, date2)

End Sub

What do you think on above excel macro topic? Please provide your input, comments, questions on excel macro. I will try to reply as soon as possible. I value your opinion on Excel Macros.

No comments:

Post a Comment

Popular Posts

Search This Blog