Date Calculation

G

Guest

I'm trying to calculate the date by using DateAdd. User will enter the data
in "Duration" value like "1.6" or "1.8" and not the whole number. When it
does the calculation it round it off to a whole number and gives an incorrect
data. Any help will be appreciated..... Thanks

=DateAdd("yyyy",Nz([Duration]),[ReleasedDate])
 
J

Jeff Boyce

Your expression tells Access to add [Duration] (or zero) years to
[ReleasedDate].

But what format are you using to display the result?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John Vinson

I'm trying to calculate the date by using DateAdd. User will enter the data
in "Duration" value like "1.6" or "1.8" and not the whole number. When it
does the calculation it round it off to a whole number and gives an incorrect
data. Any help will be appreciated..... Thanks

=DateAdd("yyyy",Nz([Duration]),[ReleasedDate])

What's the meaning of Duration? Is that 1.6 seconds, 1.6 years, 1.6
days...?

The DateAdd function takes *integer* arguments. If you intend duration
to be in years, you'll probably want to multiply by 365 and use "d"
rather than "yyyy" (it'll be a bit approximiate, but within a day or
two).

John W. Vinson[MVP]
 
G

Guest

Thank you John & Jeff. I've got it to work with John's suggestion change the
format to "d" and multiply by 365. The other thing was to change the
"Duration" format to text field instead of integer only then the value did
not rounded off.

John Vinson said:
I'm trying to calculate the date by using DateAdd. User will enter the data
in "Duration" value like "1.6" or "1.8" and not the whole number. When it
does the calculation it round it off to a whole number and gives an incorrect
data. Any help will be appreciated..... Thanks

=DateAdd("yyyy",Nz([Duration]),[ReleasedDate])

What's the meaning of Duration? Is that 1.6 seconds, 1.6 years, 1.6
days...?

The DateAdd function takes *integer* arguments. If you intend duration
to be in years, you'll probably want to multiply by 365 and use "d"
rather than "yyyy" (it'll be a bit approximiate, but within a day or
two).

John W. Vinson[MVP]
 
J

John Vinson

Thank you John & Jeff. I've got it to work with John's suggestion change the
format to "d" and multiply by 365. The other thing was to change the
"Duration" format to text field instead of integer only then the value did
not rounded off.

I would NOT recommend Text. Instead, use Number and change the type of
number to Float or Double.


John W. Vinson[MVP]
 

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

Similar Threads

Adding minutes 14
Calculate Future Date 4
Locking/unlocking cells based on column headers 5
Date/Time Calculation 1
calculating date 10
Help with small result type 2
Date Calculation 4
Calculation Time 2

Top