Date function in Forms

N

News Starstream

I just upgraded from Access 2003 to 2007 and one function doesn't work
anymore. I had one field where I entered date of purchase and another field
that was calculated by current date. It was entered in the Expression
Builder

=Date() - [date purchased]

(Date purchased is the name of the field where I enter date article was
purchased.)

This would give me the age of the article in my household inventory. Now it
gives me a value that has "19" in front of the actual age of the article.
e.g. instead of 36 years old, it gives me 1936 years old. In the property
sheet, I have the Format set at yy to give me two place setting for the
calculated result.

How do I get things working right again?


Neil
 
L

Larry Linson

Try using the DateDiff function, which is designed for subtracting one date
from another to find the number of specified units between them.

Larry Linson
Microsoft Office Access MVP
 
N

News Starstream

How do you use DateDiff with Date() ? I want to subtract an older date from
today's date.


Larry Linson said:
Try using the DateDiff function, which is designed for subtracting one
date from another to find the number of specified units between them.

Larry Linson
Microsoft Office Access MVP

News Starstream said:
I just upgraded from Access 2003 to 2007 and one function doesn't work
anymore. I had one field where I entered date of purchase and another
field that was calculated by current date. It was entered in the
Expression Builder

=Date() - [date purchased]

(Date purchased is the name of the field where I enter date article was
purchased.)

This would give me the age of the article in my household inventory. Now
it gives me a value that has "19" in front of the actual age of the
article. e.g. instead of 36 years old, it gives me 1936 years old. In the
property sheet, I have the Format set at yy to give me two place setting
for the calculated result.

How do I get things working right again?


Neil
 
J

John W. Vinson

How do you use DateDiff with Date() ? I want to subtract an older date from
today's date.

DateDiff("d", [older date], Date())

The first argument is the unit (days, "yyyy" for years, etc.); the second
argument is the first date of a range, the third is the end of the range. The
latter two can be any valid date expression.

Type Ctrl-G to open the VBA editor and search for Help on DateDiff for more
details.
 
D

Dale Fye

keep in mind that DateDiff returns the difference in the values of the
increment ("yyyy" , "m", "d") used, so it will return 1 if you try the
following in the debug window, because it is comparing 2008 to 2007.

?datediff("yyyy", #12/30/2007#, #1/1/2008#)

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



News Starstream said:
How do you use DateDiff with Date() ? I want to subtract an older date from
today's date.


Larry Linson said:
Try using the DateDiff function, which is designed for subtracting one
date from another to find the number of specified units between them.

Larry Linson
Microsoft Office Access MVP

News Starstream said:
I just upgraded from Access 2003 to 2007 and one function doesn't work
anymore. I had one field where I entered date of purchase and another
field that was calculated by current date. It was entered in the
Expression Builder

=Date() - [date purchased]

(Date purchased is the name of the field where I enter date article was
purchased.)

This would give me the age of the article in my household inventory. Now
it gives me a value that has "19" in front of the actual age of the
article. e.g. instead of 36 years old, it gives me 1936 years old. In the
property sheet, I have the Format set at yy to give me two place setting
for the calculated result.

How do I get things working right again?


Neil
 
N

News Starstream

Thanks a lot. I've got it working again.


Dale Fye said:
keep in mind that DateDiff returns the difference in the values of the
increment ("yyyy" , "m", "d") used, so it will return 1 if you try the
following in the debug window, because it is comparing 2008 to 2007.

?datediff("yyyy", #12/30/2007#, #1/1/2008#)

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



News Starstream said:
How do you use DateDiff with Date() ? I want to subtract an older date
from
today's date.


Larry Linson said:
Try using the DateDiff function, which is designed for subtracting one
date from another to find the number of specified units between them.

Larry Linson
Microsoft Office Access MVP

I just upgraded from Access 2003 to 2007 and one function doesn't work
anymore. I had one field where I entered date of purchase and another
field that was calculated by current date. It was entered in the
Expression Builder

=Date() - [date purchased]

(Date purchased is the name of the field where I enter date article
was
purchased.)

This would give me the age of the article in my household inventory.
Now
it gives me a value that has "19" in front of the actual age of the
article. e.g. instead of 36 years old, it gives me 1936 years old. In
the
property sheet, I have the Format set at yy to give me two place
setting
for the calculated result.

How do I get things working right again?


Neil
 

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