By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,484 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,484 IT Pros & Developers. It's quick & easy.

Formatting as Date in a query expression

P: n/a
Hopefully this is a simple fix. I'm writing a select query, and I want
the user to enter a start date when the query opens, so I have this
expression:

StartDate: [Enter a start date:]

So I open the query, it prompts me and records the input. However,
what I need is for access to recognize that input as a date, which it's
not. I know this because in another query I have an equation involving
my StartDate field:

xVariable: [FutureDate]-[StartDate]

which returns nothing but #Error. If I change my StartDate equation
to:

StartDate: Date()

and run my second query, it gives me the number of days difference
between my FutureDate and Date(), like I want it to. That leads me to
believe that when I change StartDate to an input, the input isn't being
read in as a date.

Easy to fix? Is there a function that will force my input to be
formatted as a date field?

Feb 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"igendreau" <ia**********@hermanmiller.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hopefully this is a simple fix. I'm writing a select query, and I want
the user to enter a start date when the query opens, so I have this
expression:

StartDate: [Enter a start date:]

So I open the query, it prompts me and records the input. However,
what I need is for access to recognize that input as a date, which it's
not. I know this because in another query I have an equation involving
my StartDate field:

xVariable: [FutureDate]-[StartDate]

which returns nothing but #Error. If I change my StartDate equation
to:

StartDate: Date()

and run my second query, it gives me the number of days difference
between my FutureDate and Date(), like I want it to. That leads me to
believe that when I change StartDate to an input, the input isn't being
read in as a date.

Easy to fix? Is there a function that will force my input to be
formatted as a date field?

While looking at your query in design view, select Query>Parameters from the
menu and enter StartDate as DateTime. When you look at the SQL of your
query, you should now have something like:

PARAMETERS [StartDate] DateTime;
SELECT * FROM MyTable WHERE
SomeDate<[StartDate];

Although, this will help letting users enter dates via an input box can lead
to some interesting results.

Feb 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.