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

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 01/07/05


Date: Fri, 7 Jan 2005 16:03:19 -0500


(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" <drew.laing@NOswvtc.dmhmrsas.virginia.SPMgov> 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
>
>


Relevant Pages

  • Insert time value in database
    ... I need to insert a time value from my ASP .Net web application in the format ... Minute:Second:Millisecond to a SQL column typed with datetime. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Creating dates from table columns
    ... varchar)+'/'+cast) as datetime) ... Asp has a dateserialmethod that ... constructs a date given a month, day and year, but sql server doesn't ...
    (comp.databases.ms-sqlserver)
  • Re: Dates
    ... I have never ever had any problems with a date in ISO 8601 format. ... The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. ... System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) +260 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to Validate a Date Filed.
    ... I'm writing, and the fourth test is just getting fancy; ... IsValid As Boolean = True) As DateTime ... > You can validate a date using Regular Expressions. ... > objects and setting culture to a country that uses the date format you ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Boolean field in dataset
    ... Crystal only formats the datetime data in the ... dataset extracted from sql database but not the datetime variable data that I ... it recognized it to be datetime field ... When I format these 2 datetime fields Crystal ...
    (microsoft.public.vb.crystal)