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

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
 

Tim K.

Registered User.
Local time
Today, 12:38
Joined
Aug 1, 2002
Messages
242
You can use DateAdd() like this.

DateAdd("YYYY",1,Now())
 
H

herbal

Guest
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
 

pono1

Registered User.
Local time
Today, 05:38
Joined
Jun 23, 2002
Messages
1,186
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
 

Tim K.

Registered User.
Local time
Today, 12:38
Joined
Aug 1, 2002
Messages
242
Or try this:

=DateAdd("YYYY",1,Date) + CDate("02:00:00 AM")
 
H

herbal

Guest
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

Top Bottom