Update Date Prompt field

G

Guest

Hello,
I am trying to subtract 90 days from a date field that I typed in a previous
query. Can anyone elucidate me on the syntax of how to write the field. This
doesn't work:
Updated Date:[DatePrompt]-90.
Thank you in advance!!
 
R

Rick Brandt

Mary said:
Hello,
I am trying to subtract 90 days from a date field that I typed in a
previous query. Can anyone elucidate me on the syntax of how to write
the field. This doesn't work:
Updated Date:[DatePrompt]-90.
Thank you in advance!!

If DatePrompt is an actual Date/Time DataType then that shoudl work. Is it?
A bit "more correct" would be...

Updated Date: DateAdd("d", -90, [DatePrompt])

....but if DatePrompt is a text field that just happens to have text that
looks like a date in it then neither your expression nor mine will work.
 
D

Douglas J. Steele

You need to ensure that Access knows that what's in DatePrompt is a date,
not text.

With the query open in Design mode, select Parameters from the Query menu.
Type DatePrompt as the Parameter, and Date/Time as its Data Type.

Alternative, you can use the CDate function:

Updated Date:CDate([DatePrompt])-90
 

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