Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Select statement with DATE


Message #1 by "aaron" <agflem@y...> on Tue, 2 Jul 2002 14:57:01 -0400
aaron,
	try changing the style in the CONVERT function to 121
Nick

-----Original Message-----
From: aaron [mailto:agflem@y...]
Sent: 02 July 2002 19:57
To: sql language
Subject: [sql_language] Select statement with DATE


I have this ASP that gives me today's date:

<%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim strToday, strDate, strDay, strMonth
strToday=Now()
strDate=Year(strtoday) & "-"
strMonth=Month(strtoday)
 If Len(strMonth)=1 then strMonth="0" & strMonth
 strMonth=strMonth & "-"
strDay=Day(strtoday)
 If Len(strDay)=1 then strDay="0" & strDay
strDate=strDate & strMonth & strDay
response.write strDate
%>

which works just fine - 

I then have a field column in SQL that holds file change info formatted
like this:
2002-06-24 15:26:57.000

// problem //
I use this statement in an ASP to find out who did what today:

SELECT count(c_date) as today
FROM table1
WHERE CONVERT(char(10),c_date,101) like '2002-07-02%' --<- Whatever the
value of strDate was...

I am sure the syntax in the WHERE clause could be off a little...

This will be ultimately used with one ASP page returning the results
into a table, but for now I am just trying to get the SQL statement to
return the proper result in Query Analyzer.


Any help is greatly appriciated.

af









*********************************************************************
This message and any attachments are confidential and should only be
read by those to whom they are addressed. If you are not the intended
recipient, please contact us, delete the message from your computer 
and destroy any copies. Any distribution or copying without our prior
permission is prohibited. 

The Achilles Group does not accept legal responsibility for the 
contents of this message. The recipient is responsible for verifying 
its authenticity before acting on the contents. Any views or opinions 
presented are solely those of the author and do not necessarily 
represent those of the Achilles Group.

This email has been scanned by MAILsweeper and Sophos Anti-Virus 
products. However, The Achilles Group will have no liability for any 
viruses contained in this email or any attachment with this email.
*********************************************************************


  Return to Index