Expiration date = 1 year from today @ 2:00 AM

  • Thread starter Thread starter herbal
  • Start date Start date
H

herbal

Guest
How would I go about setting my default value in Access to be one year from today at 2:00 AM? My older DB only used the date minus the time and that code looked like this "Date()+364".

All help will be greatly appreciated.

Herbal
 
You can use DateAdd() like this.

DateAdd("YYYY",1,Now())
 
close but no cigar

Thanks for the post, however, this won't solve my problem. I need the date to be one year from whenever a member is added at 2:00 AM. So, if its 3:30 PM on 5/1/03 that the member is added, I'd like the expiration date to be 5/1/04 at 2:00 AM.

Thanks again,
Herbal
 
Herbal,

The solution is essentially there. You just need to take it one step further, using the hour "interval argument" with another Dateadd after you've added a year. In code (open a test form, add a command button, pasting the code in the Click Event of the button), it would go something like this.

Code:
'Set up a variable in memory.
	Dim ExpDate as Date

'Add 1 year to today's date and assign this value to the variable.
	ExpDate = DateAdd("YYYY",1,Date)

'Add two more hours to ExpDate.
	ExpDate = 'Add 2 hours to ExpDate here

'Test It: Print ExpDate value to Immediate Window on VBA screen
	Debug.print ExpDate

Regards,
Tim
 
Or try this:

=DateAdd("YYYY",1,Date) + CDate("02:00:00 AM")
 
Thanks a million guys! I really appreciate it. This thing is working great now. You guys have put me one step closer to financial stability. You should be so proud!!! Thanks again, guys, I really mean it.

Herbal
 

Users who are viewing this thread

Back
Top Bottom