Results 1 to 4 of 4

Thread: birth date 1900-01-01 00:00:00.000

  1. #1
    Join Date
    Jul 2004
    Location
    bay area
    Posts
    61

    birth date 1900-01-01 00:00:00.000

    Hi,all,

    How to check the default value set up for datetime field? The reason I am asking is my database

    field "birthday" is datetime(8), the default value I set to '' already. Everytime my asp program
    have empty birthday or invalid birthdate for this field, the system automaticaly set it to

    1900-01-01 00:00:00.000

    Do you know what happened?

    Thanks!
    Betty

  2. #2
    Join Date
    Feb 2003
    Posts
    1,048
    Well empty isn't a valid value for a date field. SQL Server is interpreting '' to mean that datetime value. This is by design. Use Null instead.

    If the field is defined as a datetime field, how can there be an invalid datetime in the field? Can you show an example of what you mean?

    Run this to see what I mean:

    Select Cast('' as datetime)
    Select Cast(Null as datetime)

  3. #3
    Join Date
    Jul 2004
    Location
    bay area
    Posts
    61
    Rowhide,
    When I ran


    Select Cast('' as datetime)

    it does show

    1900-01-01 00:00:00.000

    When run

    Select Cast(NULL as datetime)
    It returns NULL.
    What should I do to avoid this?
    Thanks!
    Betty

  4. #4
    Join Date
    Feb 2003
    Posts
    1,048
    Remove the default from the field. Your ASP code can handle Null values a lot better than pretend dates.

Posting Permissions

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