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
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
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:
[vba]debug.Print Now()-300[/vba]
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,
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
Mike
Ken's method should work but you also might want to take a look at the DateAdd function or the DateDiff function.
Thank you Ken,
Works perfectly.
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!
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!