I have been using the code below to substract 2 given dates to get days:
nbDays = DateDiff("d",date2 - date1)
date1 example : "2009-03-06" ( 06 march )
date2 example : "02Feb09"
I have
date2 = Left(date2, 2) & "-" & Mid(date2, 3, 3) & "-" & Right(date2,2)
then
date2= Format(date2, "dd/mm/yyyy")
I then substract with DateDiff and it worked nicely
Since I had to reinstalled windows and Excel, the format doesn't work any more and the date "02-Feb-09" remains unchanged, which brings up an exception in DateDiff.
I can't figure out why. Any ideas?
nbDays = DateDiff("d",date2 - date1)
date1 example : "2009-03-06" ( 06 march )
date2 example : "02Feb09"
I have
date2 = Left(date2, 2) & "-" & Mid(date2, 3, 3) & "-" & Right(date2,2)
then
date2= Format(date2, "dd/mm/yyyy")
I then substract with DateDiff and it worked nicely
Since I had to reinstalled windows and Excel, the format doesn't work any more and the date "02-Feb-09" remains unchanged, which brings up an exception in DateDiff.
I can't figure out why. Any ideas?