How to get SQL Server GETDATE to return the same format as ASP Date()

How to get SQL Server GETDATE to return the same format as ASP Date()

am 07.01.2005 21:54:03 von Drew

I have an ASP application which inserts 3 fields into a database. The 3
fields are, Name, Dept and DateGenerated. The DateGenerated field is
populated by the VBScript function, Date(). I need to filter the results by
today's date, but can't figure out how to trim GETDATE() to match the date
format that is entered. The date format that is inserted looks like this,
1/7/2005.

Thanks,
Drew

Re: How to get SQL Server GETDATE to return the same format as ASP Date()

am 07.01.2005 22:03:19 von ten.xoc

(a) Have ASP send a logical and unambiguous date format, e.g. YYYYMMDD

(b) Don't think about "trimming" datetime values, they are not strings! If
you have an index on your DATETIME column, your best bet is going to be:

DECLARE @dt SMALLDATETIME
SET @dt = '20050107'
SELECT cols
FROM tbl
WHERE DateGenerated >= @dt
AND DateGenerated < @dt

--
http://www.aspfaq.com/
(Reverse address to reply.)




"Drew" wrote in message
news:uhW7GsP9EHA.1084@TK2MSFTNGP15.phx.gbl...
> I have an ASP application which inserts 3 fields into a database. The 3
> fields are, Name, Dept and DateGenerated. The DateGenerated field is
> populated by the VBScript function, Date(). I need to filter the results
by
> today's date, but can't figure out how to trim GETDATE() to match the date
> format that is entered. The date format that is inserted looks like this,
> 1/7/2005.
>
> Thanks,
> Drew
>
>