Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateAdd

Status
Not open for further replies.

NFLDUser

IS-IT--Management
Apr 17, 2006
47
CA
I am using DateAdd but causing problems when I change to another month. Any ideas on how to get this to work?

I am looking to just find a way to add a day to a specific date, but for it to automatically go to the next month if necessary ... and I am stumped!


updateDay (100, Format(DateAdd("d", 1, monthControl.Date), "MM/DD/YYYY"), ctMDay2)


Thanks!!!
 
Simply Put:

Dim ThisDate as Date

ThisDate = DateAdd("M", -1, Now)''this returns one month ago

ThisDate = DateAdd("W", -1, Now)''this returns one week ago

ThisDate = DateAdd("D", 1, Now)''This returns tomorrow's date.

ThisDate = DateAdd("D", -1, Now)''This returns yesterday's date.

I hope this helps

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
Your example should do that.

If "monthControl.Date" is the last day of a month then "DateAdd("d", 1, monthControl.Date)" will return the first of the following month. Is that not what's happening?
 
Sorry, yes that was right.

My problem was a few lines beyond this.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top