Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Dates in SQL Server

    Hello,

    I have an ASP form that has a Date field. The form is used to update data in an SQL Server. The problem I have is that when the user updates the date to say 01/07/2003, the date is saved to the Table as 01/01/1900. If anyone has any ideas, it would be appreciated.

    Thanks.
    Brent Guest

  2. Similar Questions and Discussions

    1. Between Dates
      I am trying to query an online access database and return records that have occurred between dates. I am using another query which does work to...
    2. ASP/VBS Dates Between Dates
      I'm trying to filter records depending on 2 dates requested from the querystring MMColParam1 (startdate) and MMColParam2 (enddate), i.e. a list...
    3. Dates
      Thanks to all those who replied. I ended up doing some research myself and found a good date module at...
    4. can't insert dates in SQL Server 2000
      Perhaps that's because what you're actually converting is 31 divided by 7 divided by 2003 instead of the string '31/07/2003'. Ray at home --...
    5. Server has converted dates from dd/mm/yyyy to mm/dd/yyy
      YOUR profile says dd/mm/yyyy. However, asp does not run using your profile. Check the profile of the IUSR account, and any other profile that exists...
  3. #2

    Default Re: Dates in SQL Server

    By far the best way to handle dates is to convert them to ISO date format:

    20040116 would work, but 2004-01-16 is better (works on Access too).
    Times should follow the hh:mm:ss format.

    When you pull the dates out again they should be in a suitable format, but
    if not you can set Session.LCID to an
    appropriate value for you country.

    hth

    CJM

    "Brent" <anonymous@discussions.microsoft.com> wrote in message
    news:C6E1CD30-B8FD-468A-B3FD-096519E8548C@microsoft.com...
    > Hello,
    >
    > I have an ASP form that has a Date field. The form is used to update data
    in an SQL Server. The problem I have is that when the user updates the date
    to say 01/07/2003, the date is saved to the Table as 01/01/1900. If anyone
    has any ideas, it would be appreciated.
    >
    > Thanks.

    CJM Guest

  4. #3

    Default Re: Dates in SQL Server

    For SQL server, as opposed to SQL Server 2000:
    From the Microsoft Knowledge Base:

    SYMPTOMS
    Any local variable of fixed length for which there is an implicit or
    explicit conversion to SMALLDATETIME will inadvertently convert NULL to the
    default date Jan 1, 1900 12:00AM.

    A fixed length binary variable will also convert NULL to the default date
    when the IMPLICIT conversion is to DATETIME.

    WORKAROUND
    To work around this problem, use variables of variable length rather than
    fixed length.

    STATUS
    Microsoft has confirmed this to be a problem in SQL Server versions 4.2x,
    6.0, and 6.5. We are researching this problem and will post new information
    here in the Microsoft Knowledge Base as it becomes available.

    HTH

    Steve G

    "Brent" <anonymous@discussions.microsoft.com> wrote in message
    news:C6E1CD30-B8FD-468A-B3FD-096519E8548C@microsoft.com...
    > Hello,
    >
    > I have an ASP form that has a Date field. The form is used to update data
    in an SQL Server. The problem I have is that when the user updates the date
    to say 01/07/2003, the date is saved to the Table as 01/01/1900. If anyone
    has any ideas, it would be appreciated.
    >
    > Thanks.

    Steve G Guest

  5. #4

    Default Re: Dates in SQL Server

    > 20040116 would work, but 2004-01-16 is better (works on Access too).

    Actually, the latter can break in SQL Server. The two "unbreakable" formats
    for SQL Server are:

    YYYYMMDD
    YYYY-MM-DDTHH:MM:SS[.sss]

    Note that the T is literal, e.g. 2004-01-16T11:04:32.444

    And of course, Access doesn't accept either of those, and your suggestion is
    the only "unbreakable" format I know for Access.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]



    > Times should follow the hh:mm:ss format.
    >
    > When you pull the dates out again they should be in a suitable format, but
    > if not you can set Session.LCID to an
    > appropriate value for you country.
    >
    > hth
    >
    > CJM
    >
    > "Brent" <anonymous@discussions.microsoft.com> wrote in message
    > news:C6E1CD30-B8FD-468A-B3FD-096519E8548C@microsoft.com...
    > > Hello,
    > >
    > > I have an ASP form that has a Date field. The form is used to update
    data
    > in an SQL Server. The problem I have is that when the user updates the
    date
    > to say 01/07/2003, the date is saved to the Table as 01/01/1900. If
    anyone
    > has any ideas, it would be appreciated.
    > >
    > > Thanks.
    >
    >

    Aaron Bertrand [MVP] Guest

  6. #5

    Default Re: Dates in SQL Server

    Are you sure the date field is not "time only"?

    "Brent" <anonymous@discussions.microsoft.com> wrote in message
    news:C6E1CD30-B8FD-468A-B3FD-096519E8548C@microsoft.com...
    > Hello,
    >
    > I have an ASP form that has a Date field. The form is used to update data
    in an SQL Server. The problem I have is that when the user updates the date
    to say 01/07/2003, the date is saved to the Table as 01/01/1900. If anyone
    has any ideas, it would be appreciated.
    >
    > Thanks.

    David Morgan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139