Date Calculator

O

Olduke

Will said:
Can someone point me to some Visual Basic or Access functions that would do
calculations on dates? Given as input the date and some number of days
before that date, I want as output the correct adjusted calendar date (e.g.,
2/2/2008 minus 3 days = 1/30/2008).

--

I'm a little rusty on this so if the code is wrong, perhaps someone will
correct it.

In the calculated date field add the following code:

=DateAdd("d" -3,[OriginalDateField])
 
K

Klatuu

You can use the DateAdd function for that:

dtmNewDate = DateAdd("d", -3, Me.InputDate)

If you need something more sophisticated that will not include week ends or
holidays, post back and I can send you a function that will do that.
 
W

Will

Can someone point me to some Visual Basic or Access functions that would do
calculations on dates? Given as input the date and some number of days
before that date, I want as output the correct adjusted calendar date (e.g.,
2/2/2008 minus 3 days = 1/30/2008).
 
F

fredg

Can someone point me to some Visual Basic or Access functions that would do
calculations on dates? Given as input the date and some number of days
before that date, I want as output the correct adjusted calendar date (e.g.,
2/2/2008 minus 3 days = 1/30/2008).

In addition to the other DateAdd function, how about
=[DateField]-3
 
K

Klatuu

That works, but I prefer always using date functions when dealing with date
data types. It isn't required, but It is just my preference. It is sort of
like always qualifying controls with Me. or Me! It still works, but IMHO,
just good policy.
--
Dave Hargis, Microsoft Access MVP


fredg said:
Can someone point me to some Visual Basic or Access functions that would do
calculations on dates? Given as input the date and some number of days
before that date, I want as output the correct adjusted calendar date (e.g.,
2/2/2008 minus 3 days = 1/30/2008).

In addition to the other DateAdd function, how about
=[DateField]-3
 
L

Linq Adams via AccessMonster.com

And, of course, [DateField]-3 ONLY works for days, while the OP asked for
someone to

"point me to some Visual Basic or Access functions that would do calculations
on dates"

DateAdd() works with ALL components of Date/Time fields.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top