sqlserver datetime problem

Results 1 to 2 of 2

Thread: sqlserver datetime problem

  1. #1
    Join Date
    Dec 1969

    Default sqlserver datetime problem

    i am having a problem entering a into a smalldatetime field.<BR>I have two fields,<BR>1) born smalldatetime <BR>2) died smalldatetime<BR><BR>both allow nulls and are by default set to &#060;NULL&#062;.<BR>When someone enters the date e.g. 2/2/1943 in the born field it it chops it correctly and saves it as 2/2/43. If I resave it again it saves it as 2/2/2043. (I guess this is because of the "floating 50 year time/date window...).<BR><BR>Now, on my "died" field for some reason if you don&#039t enter a value and save it... it saves it with a value of 1/1/1900.<BR><BR>I have all fields set correctly, allow nulls on them etc. checked my code and everything but can&#039t come up with a solution.<BR><BR>Does anyone know how to get around these problems?<BR>Thanks so much,<BR>Andre<BR>

  2. #2
    SPG Guest

    Default RE: sqlserver datetime problem

    Option 1: Write an algorithm which, if your len(year) &#060; 4, will figure out when your user was born or died (though not necessarily in that order).<BR><BR>Option 2: I remember seeing in an options menu (sorry, I don&#039t remember where exactly as I didn&#039t have problems with it), that you can set SQL Server 7 to state that 2-digit dates before ## are 20## and after are 19##.<BR><BR>Any way you cut it, you&#039re probably going to run into issues for anybody who&#039s 98 years old +/- a bit...<BR><BR>Spare Question: Would it be possible for you to add a constraint where &#039bornDate &#060;= buriedDate&#039? The use of NULLs might cause problems here, but if it works then it&#039ll throw an error any time somebody claims to have died before they lived.

Posting Permissions

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