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. Advertisements

  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. Advertisements

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. Replies:
    3
    Views:
    8,276
    elizas
    Apr 27, 2010
  2. =?Utf-8?B?SlA=?=
    Replies:
    1
    Views:
    7,528
    Steve C. Orr [MVP, MCSD]
    Aug 10, 2005
  3. =?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,982
    Steven Cheng[MSFT]
    Feb 16, 2006
  4. Mark C
    Replies:
    0
    Views:
    1,144
    Mark C
    Nov 5, 2007
  5. ecoolone
    Replies:
    0
    Views:
    957
    ecoolone
    Jan 3, 2008
  6. Belinda
    Replies:
    4
    Views:
    628
    Bob Barrows [MVP]
    Jun 11, 2004
  7. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    505
    Mark Schupp
    Aug 9, 2004
  8. weiwei

    asp and sql statement in sql server db

    weiwei, Sep 22, 2004, in forum: ASP General
    Replies:
    3
    Views:
    371
    Jeff Cochran
    Sep 22, 2004
Loading...