PDA

View Full Version : Solved: Date of 365 days ago.



ukemike
04-11-2005, 11:08 AM
Hey guys.
How can i find out the date (mm/dd/yyyy) of an x number of days from now backwards.
Eg: what date would it be 300 days before 4/11/2005.


Thank you
Mike

Ken Puls
04-11-2005, 11:30 AM
Hi Mike,

Providing that your date is in the correct date format, it's actually a number. You should be able to just subtract 300 form it.

Try throwing this in the immediate window and pressing enter. It should show you today's date - 300 days:

debug.Print Now()-300

As long as your date is not a text string, you should be fine. If it is text, you'll need to convert it to a valid date first.

HTH,

Norie
04-12-2005, 06:14 AM
Mike

Ken's method should work but you also might want to take a look at the DateAdd function or the DateDiff function.

ukemike
04-13-2005, 07:56 AM
Thank you Ken,
Works perfectly.

Ken Puls
04-13-2005, 08:45 AM
Glad to be of help!

FYI, though, if you ever need to add x months or years to a date though, be sure to check out Norie's suggestions, as they can be smart enough to deal with leap years and such.

Cheers!