Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 30th, 2004, 11:11 PM
Registered User
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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
 
Old May 30th, 2004, 11:17 PM
Registered User
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I tried datevalue() function but it gave me following 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


 
Old May 31st, 2004, 02:26 PM
Authorized User
 
Join Date: May 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does this work for you?

WHERE (((Str(transactions.[Date Request])) Like "*" & "5/31/2004" & "*"))
 
Old June 2nd, 2004, 09:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by Bob Hansen
WHERE (((Str(transactions.[Date Request])) Like "*" & "5/31/2004" & "*"))
Try not to get into the habit of treating dates like text. MtAlam's original statement is correct using the # delimiter for dates, but I do have one question. What is the purpose of the WHERE 1 = 1 portion of your statement?

Quote:
quote:SELECT transactions.ChangeRequest FROM transactions WHERE 1=1 AND transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status
Perhaps you should change that to

Code:
"SELECT transactions.ChangeRequest FROM transactions WHERE transactions.[Date Request] = #5/31/2004# ORDER BY transactions.Status"
And if you're doing this on a form where the date request is on a textbox, then

Code:
"SELECT transactions.ChangeRequest FROM transactions WHERE transactions.[Date Request] = #" & Me.txtDateRequest & "# ORDER BY transactions.Status"
Where you replace Me.txtDateRequest with the real name of your textbox.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old June 2nd, 2004, 06:20 PM
Authorized User
 
Join Date: May 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I saw nothing strange with the "1=1" part. I cannot speak for mtalam, but I have used 1=1 for years as a quick way to en/dis -able certain functions. Make it 1=0 to disable, and 1=1 to enable it.
 
Old June 3rd, 2004, 06:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by Bob Hansen
I have used 1=1 for years as a quick way to en/dis -able certain functions. Make it 1=0 to disable, and 1=1 to enable it.
Ahhhhh... so that's what that's for. I just comment / uncomment the function.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Use DateTime Field kcsathish ASP.NET 2.0 Professional 0 July 15th, 2008 01:01 AM
Datetime Field as index daworm MySQL 2 September 17th, 2006 11:33 PM
A doubt in DateTime field dhol General .NET 1 December 30th, 2004 01:33 PM
How do you search datetime field? SoC Classic ASP Basics 6 October 31st, 2004 09:39 PM
Searching datetime field SoC Classic ASP Databases 2 October 29th, 2004 10:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.