473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Date in Query

I have a Query that consist of a lot of different sales data, and one of the
colums are different date. The date goes from 1jan2003 til 31jan2003. in
this Query I only want the salesdata for 1jan2003. How do I remove the dates
, 2jan2003 til 31jan2003 without removing them from the table, from the
Query? (Because I want to use the data for 2jan2003 etc later in other
queries)

-kenneth
Nov 12 '05 #1
10 1233
Example:

Select * From tblMyTable Where DateField = #1/1/2003#

This will select all records from the table where the date field is 1 Jan
2003. The query wants the date formatted in US format. The # signs are date
delimiters so that Access knows that this is a date and not division. If you
are going to make multiple queries such as this one, you may want to look in
the help file for Parameter Queries. This will cause the query to prompt you
for the date when you run it.

--
Wayne Morgan
Microsoft Access MVP
"Kenneth" <sn*******@hotmail.com> wrote in message
news:c6**********@dolly.uninett.no...
I have a Query that consist of a lot of different sales data, and one of the colums are different date. The date goes from 1jan2003 til 31jan2003. in
this Query I only want the salesdata for 1jan2003. How do I remove the dates , 2jan2003 til 31jan2003 without removing them from the table, from the
Query? (Because I want to use the data for 2jan2003 etc later in other
queries)

-kenneth

Nov 12 '05 #2
I have tried the formula:
Select * From tblMyTable Where DateField = #1/1/2003#

and changed MyTable to Date, which is the name of my column with date, but
it doesn't work.

Have I done anything wrong?

-kenneth

--
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:VJ**************@newssvr16.news.prodigy.com.. .
Example:

Select * From tblMyTable Where DateField = #1/1/2003#

This will select all records from the table where the date field is 1 Jan
2003. The query wants the date formatted in US format. The # signs are date delimiters so that Access knows that this is a date and not division. If you are going to make multiple queries such as this one, you may want to look in the help file for Parameter Queries. This will cause the query to prompt you for the date when you run it.

--
Wayne Morgan
Microsoft Access MVP
"Kenneth" <sn*******@hotmail.com> wrote in message
news:c6**********@dolly.uninett.no...
I have a Query that consist of a lot of different sales data, and one of

the
colums are different date. The date goes from 1jan2003 til 31jan2003. in
this Query I only want the salesdata for 1jan2003. How do I remove the

dates
, 2jan2003 til 31jan2003 without removing them from the table, from the
Query? (Because I want to use the data for 2jan2003 etc later in other
queries)

-kenneth


Nov 12 '05 #3
Kenneth wrote:
I have tried the formula:
Select * From tblMyTable Where DateField = #1/1/2003#

and changed MyTable to Date, which is the name of my column with date, but
it doesn't work.

Have I done anything wrong?
Yes. What is your table name? Go to the database window and select
Tables. Find out what the table name is your are designing your query
around. Tmen substitute tblMyTable to that name. Now open the table in
design mode. Determine the name of your date field to filter on. Close
the table. Substitute DateField with the name of the field.

Did you have a brain freeze :-)


-kenneth

--
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:VJ**************@newssvr16.news.prodigy.com.. .
Example:

Select * From tblMyTable Where DateField = #1/1/2003#

This will select all records from the table where the date field is 1 Jan
2003. The query wants the date formatted in US format. The # signs are


date
delimiters so that Access knows that this is a date and not division. If


you
are going to make multiple queries such as this one, you may want to look


in
the help file for Parameter Queries. This will cause the query to prompt


you
for the date when you run it.


Nov 12 '05 #4
The name of my table is "deliveries", and my column inside that table is
named "date".
The formula now is then:
Expr1: (Select * From [levering] Where date = #1/1/2003#)
but this gives me an errormessage:
"You have written a subquery that can return more than one field without
using the EXISTS reserved word in the main query's FROM clause. Revise the
select statement of the subquery to request only one field."

How do I "Determine the name of your date field to filter on"?

-kenneth

....my brain needs a quick start up :)

--

"Salad" <oi*@vinegar.com> wrote in message
news:C6******************@newsread1.news.pas.earth link.net...
Kenneth wrote:
I have tried the formula:
Select * From tblMyTable Where DateField = #1/1/2003#

and changed MyTable to Date, which is the name of my column with date, but it doesn't work.

Have I done anything wrong?


Yes. What is your table name? Go to the database window and select
Tables. Find out what the table name is your are designing your query
around. Tmen substitute tblMyTable to that name. Now open the table in
design mode. Determine the name of your date field to filter on. Close
the table. Substitute DateField with the name of the field.

Did you have a brain freeze :-)


-kenneth

--
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:VJ**************@newssvr16.news.prodigy.com.. .
Example:

Select * From tblMyTable Where DateField = #1/1/2003#

This will select all records from the table where the date field is 1 Jan2003. The query wants the date formatted in US format. The # signs are


date
delimiters so that Access knows that this is a date and not division. If


you
are going to make multiple queries such as this one, you may want to
look
in
the help file for Parameter Queries. This will cause the query to prompt


you
for the date when you run it.

Nov 12 '05 #5
You are not using "deliveries" as the table. Also you have named a
column using an Access reserved word (date) - you are most likely
confusing Access. Rename the field to something else (not reserved,
that is). The SQL statement should be fine then.

Select * From deliveries Where Mydate = #1/1/2003#

- Jim

On Thu, 29 Apr 2004 23:59:21 +0200, "Kenneth" <sn*******@hotmail.com>
wrote:
The name of my table is "deliveries", and my column inside that table is
named "date".
The formula now is then:
Expr1: (Select * From [levering] Where date = #1/1/2003#)
but this gives me an errormessage:
"You have written a subquery that can return more than one field without
using the EXISTS reserved word in the main query's FROM clause. Revise the
select statement of the subquery to request only one field."

How do I "Determine the name of your date field to filter on"?

-kenneth

...my brain needs a quick start up :)

--

"Salad" <oi*@vinegar.com> wrote in message
news:C6******************@newsread1.news.pas.eart hlink.net...
Kenneth wrote:
> I have tried the formula:
> Select * From tblMyTable Where DateField = #1/1/2003#
>
> and changed MyTable to Date, which is the name of my column with date,but > it doesn't work.
>
> Have I done anything wrong?


Yes. What is your table name? Go to the database window and select
Tables. Find out what the table name is your are designing your query
around. Tmen substitute tblMyTable to that name. Now open the table in
design mode. Determine the name of your date field to filter on. Close
the table. Substitute DateField with the name of the field.

Did you have a brain freeze :-)

>
> -kenneth
>
> --
> "Wayne Morgan" <co***************************@hotmail.com> wrote inmessage > news:VJ**************@newssvr16.news.prodigy.com.. .
>
>>Example:
>>
>>Select * From tblMyTable Where DateField = #1/1/2003#
>>
>>This will select all records from the table where the date field is 1Jan >>2003. The query wants the date formatted in US format. The # signs are
>
> date
>
>>delimiters so that Access knows that this is a date and not division. If
>
> you
>
>>are going to make multiple queries such as this one, you may want tolook >
> in
>
>>the help file for Parameter Queries. This will cause the query to prompt
>
> you
>
>>for the date when you run it.
>>



Nov 12 '05 #6
My Tables is still named deliveries, but my date-column is named "MyDate"
now.
My formula is like this:
Expr1: [Select * From deliveries Where MyDate = #1/1/2003#]

but when I select the "query view" then I get this message:
"Enter Parameter Value. select * From deliveries Where MyDate = #1/1/2003#"

I still see all my rows (with date 1/1/2003, 2/1/2003 etc.) but the new
column consist of whatever I add in the "Enter Parameter Value"-field.

What is wrong this time, and what should I do?

-kenneth

--

"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message
news:40****************@news.west.earthlink.net...
You are not using "deliveries" as the table. Also you have named a
column using an Access reserved word (date) - you are most likely
confusing Access. Rename the field to something else (not reserved,
that is). The SQL statement should be fine then.

Select * From deliveries Where Mydate = #1/1/2003#

- Jim

On Thu, 29 Apr 2004 23:59:21 +0200, "Kenneth" <sn*******@hotmail.com>
wrote:
The name of my table is "deliveries", and my column inside that table is
named "date".
The formula now is then:
Expr1: (Select * From [levering] Where date = #1/1/2003#)
but this gives me an errormessage:
"You have written a subquery that can return more than one field without
using the EXISTS reserved word in the main query's FROM clause. Revise theselect statement of the subquery to request only one field."

How do I "Determine the name of your date field to filter on"?

-kenneth

...my brain needs a quick start up :)

--

"Salad" <oi*@vinegar.com> wrote in message
news:C6******************@newsread1.news.pas.eart hlink.net...
Kenneth wrote:

> I have tried the formula:
> Select * From tblMyTable Where DateField = #1/1/2003#
>
> and changed MyTable to Date, which is the name of my column with date,
but
> it doesn't work.
>
> Have I done anything wrong?

Yes. What is your table name? Go to the database window and select
Tables. Find out what the table name is your are designing your query
around. Tmen substitute tblMyTable to that name. Now open the table

in design mode. Determine the name of your date field to filter on. Close the table. Substitute DateField with the name of the field.

Did you have a brain freeze :-)
>
> -kenneth
>
> --
> "Wayne Morgan" <co***************************@hotmail.com> wrote in

message
> news:VJ**************@newssvr16.news.prodigy.com.. .
>
>>Example:
>>
>>Select * From tblMyTable Where DateField = #1/1/2003#
>>
>>This will select all records from the table where the date field is 1

Jan
>>2003. The query wants the date formatted in US format. The # signs are >
> date
>
>>delimiters so that Access knows that this is a date and not division. If >
> you
>
>>are going to make multiple queries such as this one, you may want to

look
>
> in
>
>>the help file for Parameter Queries. This will cause the query to prompt >
> you
>
>>for the date when you run it.
>>



Nov 12 '05 #7
Kenneth wrote:
My Tables is still named deliveries, but my date-column is named "MyDate"
now.
My formula is like this:
Expr1: [Select * From deliveries Where MyDate = #1/1/2003#]

but when I select the "query view" then I get this message:
"Enter Parameter Value. select * From deliveries Where MyDate = #1/1/2003#"

I still see all my rows (with date 1/1/2003, 2/1/2003 etc.) but the new
column consist of whatever I add in the "Enter Parameter Value"-field.

What is wrong this time, and what should I do?

-kenneth


I don't think Access wants you to enter into one column your entire
select statement. BTW. the [] around your statement indicates to
Access that your select statement is a field. If in a criteria row, a
parameter.

The easiest way to get you back on track is to click on the query tab,
select New/Design. Select your Delivery table, click Close. Now drag
the * in the table delivery table to the field row. Drag the field
MyDate to the second row. Uncheck the SHOW checkbox. Enter #1/1/2003#
in the criteria row for MyDate.

Click View/Datasheet from the menu to check the results. Click View/SQL
to see the SQL Statement.

One other thing. You could copy the SQL statement in your expression,
and then click View/SQL and cut out whatever you currently have and
paste in the statement from your expression.

Definite brain freeze.

Nov 12 '05 #8
Hi-

I have a table with dates in it also. I usually use a parameter
expression in the criteria box for the field I want to use.

For example: I have a field named ContactDate. In "Design View" of my
query, I enter the following criteria for ContactDate:

Between [Enter Beginning Date] And [Enter Ending Date]

Then when I run the query, I can enter the beginning date and the
ending date.

The text between the braces, [], can be anything you want. I usually
say "Enter Beginning Date" and "Enter Ending Date" so that the user
knows what to enter. The text between the braces, [], are instructions
for what you want the user to enter. For example if you're searching
for a country, it would be: [Enter a Country]. The limiting is done by
the keywords, "Between" and "And."

However when I tried the criteria: [Enter a Date] for ContactDate, my
query only returned 1 record when I have 3. So, I'm not sure how well
it will work for a single date with multiple records.

Well I hope this gave you another idea even though I don't know how to
get a single date to return more than 1 record. I'm looking through
one of my books, Microsoft Access 2002 Inside Out. If I find an
answer, I'll post it!

Hope this gives you an idea,

Megan
Nov 12 '05 #9
Megan wrote:
Hi-

I have a table with dates in it also. I usually use a parameter
expression in the criteria box for the field I want to use.

For example: I have a field named ContactDate. In "Design View" of my
query, I enter the following criteria for ContactDate:

Between [Enter Beginning Date] And [Enter Ending Date]

Then when I run the query, I can enter the beginning date and the
ending date.

The text between the braces, [], can be anything you want. I usually
say "Enter Beginning Date" and "Enter Ending Date" so that the user
knows what to enter. The text between the braces, [], are instructions
for what you want the user to enter. For example if you're searching
for a country, it would be: [Enter a Country]. The limiting is done by
the keywords, "Between" and "And."

However when I tried the criteria: [Enter a Date] for ContactDate, my
query only returned 1 record when I have 3. So, I'm not sure how well
it will work for a single date with multiple records.
It should work like a champ.
Well I hope this gave you another idea even though I don't know how to
get a single date to return more than 1 record. I'm looking through
one of my books, Microsoft Access 2002 Inside Out. If I find an
answer, I'll post it!
I create a table called Table1. I added 3 date records. The first
record I stored Date(), the next 2 I stored Now(). I then ran a query
to select records for today. The query returned 1 record as expected.

Date stores the date and also the time of 00:00:00. So when the
criteria is Date and you have some now values ex: 4/30/2004 12:01:13
then that will never equal 4/30/2004 00:00:00.

If you have Now()'s then you need to check for equal Date and less than
Date+1.

I am curious. I have never used the [Enter Date] method in any of my
queries, forms, or reports. Do you use that method in an application or
do you use that because you mostly work with your data in the database
window? Or do you pass parameters to the query? I've seen it where the
developer had about 5 prompts in the query and each time the popup was
displayed to enter data I became more frustrated and wondered how many
more prompts I'd have to answer until I hit pay dirt.

Hope this gives you an idea,

Megan


Nov 12 '05 #10
Ken,

Access won't accept a subquery in an expession like this. If there is only
one record that will be returned by the expression, you can use DLookup
instead. What is/are the table(s) in the query in which you are trying to
add this expression?

--
Wayne Morgan
MS Access MVP
"Kenneth" <sn*******@hotmail.com> wrote in message
news:c6**********@dolly.uninett.no...
My Tables is still named deliveries, but my date-column is named "MyDate"
now.
My formula is like this:
Expr1: [Select * From deliveries Where MyDate = #1/1/2003#]

but when I select the "query view" then I get this message:
"Enter Parameter Value. select * From deliveries Where MyDate = #1/1/2003#"
I still see all my rows (with date 1/1/2003, 2/1/2003 etc.) but the new
column consist of whatever I add in the "Enter Parameter Value"-field.

What is wrong this time, and what should I do?

-kenneth

Nov 12 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Russell | last post by:
I'm having a fit with a query for a range of dates. The dates are being returned from a view. The table/field that they are being selected from stores them as varchar and that same field also...
2
by: BlackFireNova | last post by:
I have an Access 2003 mdb which contains software records. I need to sort on a particular type of software, and then identify and count how many copies there are per each group of that type...
10
by: Kenneth | last post by:
I have a Query that consist of a lot of different sales data, and one of the colums are different date. The date goes from 1jan2003 til 31jan2003. in this Query I only want the salesdata for...
7
by: Nicolae Fieraru | last post by:
Hi All, I have a table tblProducts where I have four fields:\ Index, ProductName, EnterDate (as Date/Time - Medium Date), PurchaseDate (Date/Time - Medium Date) The EnterDate is automatically...
4
by: Peter Bailey | last post by:
I have a vba string taht dynamically creates the query which has two dates in it that it grabs off an open form as a string from the textbox. What I generate in vba is: SELECT DOSMBK.Date,...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
3
by: manning_news | last post by:
Using A2K. I've been asked to modify a report currently requiring only one date parameter to now accept a date range. The main report has 2 subreports and is not bound to a table or query. The...
11
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
10
by: Daniel | last post by:
In Microsoft Access I can write a query that includes the criteria: Between Date()-7 And Date() to retrieve the records from a table that fall within the last week. I'm trying to write a...
2
by: sixdeuce62 | last post by:
Hello, I am trying to create a query that will prompt me to enter the parameter value if beginning date and ending date. I have created everything I need in the query, but I have to manually go...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.