subtract days from a date

  • Thread starter sheniece via AccessMonster.com
  • Start date
S

sheniece via AccessMonster.com

Ok. I have a form with a text box and button, the textbox take a text value
which represents the number of day. I have a table and one of the columns is
named DateCreated, I would like to take the number entered in the text box
and subtract it from a short date in a query, and return all records that
were created n days ago, currently i have this in the criteria column of the
query.

=< -10

I thought this would return all records created 10 days ago. Do i have to
convert the value i recieved in the textbox to date format.
 
M

Marshall Barton

sheniece said:
Ok. I have a form with a text box and button, the textbox take a text value
which represents the number of day. I have a table and one of the columns is
named DateCreated, I would like to take the number entered in the text box
and subtract it from a short date in a query, and return all records that
were created n days ago, currently i have this in the criteria column of the
query.

=< -10

I thought this would return all records created 10 days ago. Do i have to
convert the value i recieved in the textbox to date format.


Comparuing a date value to a number is meaningless. Use the
date manipulation function to operate on date values:

<= DateAdd("d", -Forms!theform.thetextbox, theshortdate)
 

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