Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

problem with date time field ...
Hi guys,

I have an asp page that needs to show data based on date criteria.
Basically the user selects a date and the asp page should display all
records within that day.
The problem is that this field contains date and time.

My current query is as follows:
RS.Open "Select * from DB1.dbo.logs WHERE Date = '" &
Request.Form("date") & "'", dbConn, 1

How should I modify this query so that it ignores the time ?

Thanks in advance !


Report this thread to moderator Post Follow-up to this message
Old Post
zerbie45@gmail.com
03-01-06 01:23 AM


Re: problem with date time field ...
http://www.karaszi.com/SQLServer/info_datetime.asp
http://www.karaszi.com/SQLServer/in...e.asp#Searching

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/
Blog: http:// solidqualitylearning
.com/blogs/tibor/


<zerbie45@gmail.com> wrote in message news:1141037700.450486.299340@p10g2000cwp.googlegroup
s.com...
> Hi guys,
>
> I have an asp page that needs to show data based on date criteria.
> Basically the user selects a date and the asp page should display all
> records within that day.
> The problem is that this field contains date and time.
>
> My current query is as follows:
> RS.Open "Select * from DB1.dbo.logs WHERE Date = '" &
> Request.Form("date") & "'", dbConn, 1
>
> How should I modify this query so that it ignores the time ?
>
> Thanks in advance !
>

Report this thread to moderator Post Follow-up to this message
Old Post
Tibor Karaszi
03-01-06 01:23 AM


Re: problem with date time field ...
Hey Tibor,
thanks for your reply; I'm just starting using asp and sql.
Do you know a quick way to modify this query so that it skips the time
? Your links are a bit too advanced for me.
That would be VERY appreciated.

Thanks in advance.


Report this thread to moderator Post Follow-up to this message
Old Post
zerbie45@gmail.com
03-01-06 01:23 AM


Re: problem with date time field ...
To add to Tibor's response, you can use a parameterized query to improve
performance, security and mitigate the need for date formatting.  Also,
consider using a fast-forward cursor instead of a keyset one unless you have
a specific reason to do otherwise.

Set command = CreateObject("ADODB.Command")
command.ActiveConnection = connection
command.CommandText = _
"Select * from DB1.dbo.logs WHERE Date >= ? AND Date < ? + 1"

Set dateParameter1 = command.CreateParameter( _
"@dateParameter1", 7, 1)
command.Parameters.Append dateParameter1
dateParameter1.Value = Request.Form("date")
Set dateParameter2 = command.CreateParameter( _
"@dateParameter2", 7, 1)
command.Parameters.Append dateParameter2
dateParameter2.Value = Request.Form("date")

Set RS = command.Execute()

--
Hope this helps.

Dan Guzman
SQL Server MVP

<zerbie45@gmail.com> wrote in message
news:1141037700.450486.299340@p10g2000cwp.googlegroups.com...
> Hi guys,
>
> I have an asp page that needs to show data based on date criteria.
> Basically the user selects a date and the asp page should display all
> records within that day.
> The problem is that this field contains date and time.
>
> My current query is as follows:
> RS.Open "Select * from DB1.dbo.logs WHERE Date = '" &
> Request.Form("date") & "'", dbConn, 1
>
> How should I modify this query so that it ignores the time ?
>
> Thanks in advance !
>



Report this thread to moderator Post Follow-up to this message
Old Post
Dan Guzman
03-01-06 01:23 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 10:38 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006