Dates dates dates dates... SQL and ASP.NET

Discussion in 'ASP .Net' started by David Lozzi, Sep 29, 2005.

  1. David Lozzi

    David Lozzi Guest

    Howdy,

    Users can specify a date in a field labeled dtDate. This field in SQL is a
    smalldatetime. When I vew the raw data in the table, it displays 9/29/2008,
    and when a user doesn't specify a date it displays as 1/1/1900.

    Issue 1) When displaying the records in a datagrid, using basically all
    default configs for the datagrid, and a stored proc to query the table, the
    dates appear as such: 9/29/2005 12:00:00 AM and 1/1/1900 12:00:00 AM. WHY?!
    Why doesn't it display the data thats in the table which is ONLY the date?

    Issue 2) What's the best way to deal with the 1/1/1900 date default?

    I'm writing a calendar console so if I have to format each date field
    everytime I use it, I may go crazy. I would think that this is either a slip
    in my script or my workstation is not performing correctly....

    Thanks for your help!!

    --
    David Lozzi
    Web Applications Developer
    dlozzi@(remove-this)delphi-ts.com
     
    David Lozzi, Sep 29, 2005
    #1
    1. Advertising

  2. David Lozzi

    Rob Schieber Guest

    David Lozzi wrote:
    > Howdy,
    >
    > Users can specify a date in a field labeled dtDate. This field in SQL is a
    > smalldatetime. When I vew the raw data in the table, it displays 9/29/2008,
    > and when a user doesn't specify a date it displays as 1/1/1900.
    >
    > Issue 1) When displaying the records in a datagrid, using basically all
    > default configs for the datagrid, and a stored proc to query the table, the
    > dates appear as such: 9/29/2005 12:00:00 AM and 1/1/1900 12:00:00 AM. WHY?!
    > Why doesn't it display the data thats in the table which is ONLY the date?
    >


    You need to tell your application how to format the strings: see
    http://msdn.microsoft.com/library/d...e/html/cpconstandarddatetimeformatstrings.asp


    > Issue 2) What's the best way to deal with the 1/1/1900 date default?


    I think this is an input validation issue, make sure users enter a date,
    or find some way to handle the display of null or default dates. Bottom
    line, you need to provide the logic for this.

    >
    > I'm writing a calendar console so if I have to format each date field
    > everytime I use it, I may go crazy. I would think that this is either a slip
    > in my script or my workstation is not performing correctly....



    >
    > Thanks for your help!!
    >



    --
    Rob Schieber
     
    Rob Schieber, Sep 30, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2NvdHRybQ==?=

    sql session state for .net v1.1/.net v2.0 and sql server 2005

    =?Utf-8?B?c2NvdHRybQ==?=, Feb 13, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,809
    Steven Cheng[MSFT]
    Feb 16, 2006
  2. ecoolone
    Replies:
    0
    Views:
    782
    ecoolone
    Jan 3, 2008
  3. Belinda
    Replies:
    4
    Views:
    376
    Bob Barrows [MVP]
    Jun 11, 2004
  4. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    209
    Mark Schupp
    Aug 9, 2004
  5. David

    Dates in ASP SQL Select Statement....

    David, Apr 12, 2005, in forum: ASP General
    Replies:
    2
    Views:
    231
    dlbjr
    Apr 12, 2005
Loading...

Share This Page