Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 July 20th, 2006, 09:14 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default sql date/time

Hi,
I use ms sql db and the date field type is datetime like this:
7/15/2006 10:16:28 PM
The following query does not respond when I want to filter the records for today
I think I should use datepart function before date_signed but I do not know how??

select * from cmm_Users where date_signed=" & "'" & date() & "'" ,Conn,1,3

 
Old July 20th, 2006, 01:49 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One way to do this is to use the between keyword:
select * from cmm_Users where date_signed between ...
All of todays dates will be between date() and date() plus one day.

Woody Z http://www.learntoprogramnow.com
 
Old July 20th, 2006, 03:13 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No.The datetime format is liek this 7/15/2006 10:16:28 in db
but date() function returns this 7/15/2006
and therefore it does not return the correct value

 
Old July 20th, 2006, 07:35 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Please note I am in Aussie the date values shown here are dd/mm/yyyy

There are several ways to do this. My method of getting all records for a certain day. EG today, I would:

sql = "select * FROM cmm_Users WHERE date_signed > '" & date() & "' AND date_signed < '" & (date()+1) & "';"

[give me all records where the dat value is greater than today but less that tommorow]

FYI:
the date() function returns:
21/07/2006
However the now() function returns:
21/07/2006 10:30:25



Wind is your friend
Matt
 
Old July 21st, 2006, 01:44 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 
Quote:
quote:No.The datetime format is liek this 7/15/2006 10:16:28 in db
Quote:
but date() function returns this 7/15/2006
and therefore it does not return the correct value
You are not understanding.

By using the between keyword, which is inclusive, you will get all the "between" dates - which will be everything that has a date of the current date.

You cannont use "date_signed=" because your dates will (almost) never be equal to the "raw" date without the time portion tacked on.

What you need to do is either use the between, or the
Code:
sql = "select * FROM cmm_Users WHERE  date_signed > '" & date() & "' AND date_signed < '" & (date()+1) & "';"
that mat41 supplied.

What we are suggesting is that you need to check for dates that are within a range, and that range must include all the valid datetime entries for the date you are checking.

You see?


Woody Z http://www.learntoprogramnow.com
 
Old July 22nd, 2006, 03:20 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot
it worked
nice






Similar Threads
Thread Thread Starter Forum Replies Last Post
date and time in EST time zone anboss XSLT 1 May 21st, 2008 01:42 PM
HELP!!! retrieving time and date from SQL 2005 wearyrecca Visual Basic 2005 Basics 2 September 11th, 2007 10:28 AM
Best method to store date & Time with SQL 2000 harini19 Java Basics 0 February 15th, 2006 12:52 AM
passing date time values to sql ashokparchuri ADO.NET 4 March 15th, 2005 01:47 AM
insert system date. no date and time jimmy Access VBA 6 November 20th, 2003 01:11 PM





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