That should work, so let's work on the assumption that it is not
understanding the data types correctly.
1.) The Expr1 looks right: Access adds an alias like that.
Let's typecast the expression. Try:
Expr1: CVDate([TheDate]+[TheTime])
We are assuming here that TheDate and TheTime are both Date/Time fields in
your table (not Text fields.)
2.) It is important to declare the parameter, so Access does a date
comparsion, not a text comparison. Copy the:
[After what date and time?]
from the criteria line (without the >), open the Parameters box, and enter
it there. If you switch your query to SQL View (View menu, in query design),
you should now see:
PARAMETERS [After what date and time?] DateTime;
SELECT ...
3.) If that still isn't right, change your Regional Settings in the Windows
Control Panel so that Short Date shows the 4-digits of the year. This will
ensure the data is not a century out, as you can see the 2006 instead of 06.
If it still fails, post the whole SQL statement.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
bluezcruizer said:
Sorry, Allen, I must be doing something wrong. Here's what I've got:
Field slot 1...
Expr1: [TheDate]+[TheTime] (the "Expr1: " was added by Access)
Table (blank)
Sort (blank)
Show (checked)
Criteria: >[After what date and time?]
I've removed the field listings from the parameters box as it was asking
the
question twice.
I ran the query as a test I used "7/17/06 2:00pm" in the dialog box
requesting the parameters of the search. Prior to this, I made sure there
is
a record that would fit the bill -- it is set to 2:30pm on 7/17/06. The
query returned zero results.
Thank you for your continued help Allen.
Allen Browne said:
In query design, type this expression into the *Field* row:
[TheDate] + [TheTime]
You can now put your criteria in the Criteria row under this field.
I'm not completely sure I follow...we'll have to go with 2 different
fields
because of other requirements.
I've changed the field names to "TheDate" and "TheTime" as per your
recommendations.
So in my query, I have the field names, the first two are "TheDate" and
"TheTime"
How do I list these in the parameters box that pulls up? Do I leave
anything in the Criteria for those fields?
Thank you.
bluezcruizer
:
Simplest solution would be to use just one field that contains the
date
and
time. You could the type your criteria into the query as:
[After what date and time?]
(Note: include the greater than sign.)
Then choose Parameters on the Query menu.
In the dialog that opens, enter:
[After what date and time?] Date/Time
All done.
If you want to continue with the 2 different fields, make sure they
are
not
named Date and Time. Those are both reserved words in JET. We will use
TheDate and TheTime for this example.
Now in your query, enter this into the Field row:
[TheDate] + [TheTime]
and then continue to add the criteria and declare the parameter in the
same
way as desribed above for a combined date/time field.
to group, rather than allenbrowne at mvps dot org.
message
Hi.
I'm trying to create a query that will return records from a
specified
date
and after a specified time.
So far, I've got the table set with 2 fields; one for "date" and the
other
for "time". Both are auto inputted as the record is generated.
The query I've got I have the date criteria as [Date?]
to
return records for a specified date, and am having trouble with the
time
side
of the coin. I've currently got >[Time?] but that
seems
to
return any records regardless of what time it was inputted.
So what I'm trying to do is return say any records inputted after
2:30pm
on
7/17/06.