A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query DateTime Field



 
 
Thread Tools Display Modes
  #1  
Old May 31st, 2004, 04:33 AM
Tausif
external usenet poster
 
Posts: n/a
Default Query DateTime Field

Hi,

I have a field DateStamp, stores both date and time. I would like put a
query with which I can only compare date but not the time. I put this query
but it is not working. Please help thankx..

SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND
transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status

Thankx


  #2  
Old May 31st, 2004, 05:03 AM
Ken Snell
external usenet poster
 
Posts: n/a
Default Query DateTime Field

When you store both the time and date together in one field, you must use a
calculated field that gives you just the date portion for searching:

SELECT transactions.ChangeRequest FROM transactions
WHERE 1=1 AND
DateValue(transactions.[Date Request]) = #5/31/2004#
ORDER BY transactions.Status;

--
Ken Snell
MS ACCESS MVP



"Tausif" wrote in message
...
Hi,

I have a field DateStamp, stores both date and time. I would like put a
query with which I can only compare date but not the time. I put this

query
but it is not working. Please help thankx..

SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND
transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status

Thankx




  #3  
Old May 31st, 2004, 05:10 AM
Tausif
external usenet poster
 
Posts: n/a
Default Query DateTime Field

Hi,

THankx a lot for the help.

I used that but it gave me the error:

Data type mismatch in criteria expression.
/helpdesk/HelpDesk/HelpDesk.asp, line 400
I am using HTML as front end and ASP for database access.. thankx in
advance..

Tausif
----- Original Message -----
From: "Ken Snell"
Newsgroups: microsoft.public.access.queries
Sent: Monday, May 31, 2004 12:03 PM
Subject: Query DateTime Field


When you store both the time and date together in one field, you must use

a
calculated field that gives you just the date portion for searching:

SELECT transactions.ChangeRequest FROM transactions
WHERE 1=1 AND
DateValue(transactions.[Date Request]) = #5/31/2004#
ORDER BY transactions.Status;

--
Ken Snell
MS ACCESS MVP



"Tausif" wrote in message
...
Hi,

I have a field DateStamp, stores both date and time. I would like put a
query with which I can only compare date but not the time. I put this

query
but it is not working. Please help thankx..

SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND
transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status

Thankx






  #4  
Old May 31st, 2004, 05:22 AM
Tausif
external usenet poster
 
Posts: n/a
Default Query DateTime Field

I checked it is due to some records having NULL in the datestamp field .
Now, how can i use datevalue function.

regards,

Tausif.

"Tausif" wrote in message
...
Hi,

I have a field DateStamp, stores both date and time. I would like put a
query with which I can only compare date but not the time. I put this

query
but it is not working. Please help thankx..

SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND
transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status

Thankx




  #5  
Old May 31st, 2004, 05:22 AM
Tausif
external usenet poster
 
Posts: n/a
Default Query DateTime Field

I checked it is due to some records having NULL in the datestamp field .
Now, In this case; how can i use datevalue function.

regards,

Tausif.

"Tausif" wrote in message
...
Hi,

I have a field DateStamp, stores both date and time. I would like put a
query with which I can only compare date but not the time. I put this

query
but it is not working. Please help thankx..

SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND
transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status

Thankx





  #6  
Old May 31st, 2004, 05:23 AM
Tausif
external usenet poster
 
Posts: n/a
Default Query DateTime Field

I checked it is due to some records having NULL in the datestamp field .
Now, In this case; how can i use datevalue function.

regards,

Tausif.

"Tausif" wrote in message
...
Hi,

I have a field DateStamp, stores both date and time. I would like put a
query with which I can only compare date but not the time. I put this

query
but it is not working. Please help thankx..

SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND
transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status

Thankx





  #7  
Old May 31st, 2004, 05:23 AM
Tausif
external usenet poster
 
Posts: n/a
Default Query DateTime Field

I checked it is due to some records having NULL in the datestamp field .
Now, In this case; how can i use datevalue function.

regards,

Tausif.

"Tausif" wrote in message
...
Hi,

I have a field DateStamp, stores both date and time. I would like put a
query with which I can only compare date but not the time. I put this

query
but it is not working. Please help thankx..

SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND
transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status

Thankx





  #8  
Old May 31st, 2004, 07:54 AM
John Vinson
external usenet poster
 
Posts: n/a
Default Query DateTime Field

On Mon, 31 May 2004 11:33:20 +0800, "Tausif"
wrote:

SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND
transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status


Another approach, which is tolerant to NULLs and takes advantage of
any index on [Date Request], would be

WHERE True AND [Transactions].[Date Request] = [Enter date:] AND
[Date Request] [Enter date:] + 1

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.