all groups > sql server programming > march 2005 >
You're in the

sql server programming

group:

Dates and defaults



Dates and defaults Chris Marsh
3/9/2005 10:38:54 PM
sql server programming: Hi,

We have been working with SQL 2000 for about a year now pretty successfully
except with dates. This just doesn't seem to be correct, we came for the
VFP data world and it worked with dates easier however dates/times only
recently became one so that was always a fun calculation. In the SQL data
table design tools we can set default values for varchar's, bit and float
fields just to name a few but we cannot set a default value for dates so
they are not posted with a null or with a silly date of 1899 or 1900.

We simply want to be able to store a blank value in a date field - for
example, we have a payment received field with the date/time. A customer
has not been paid yet so the date/time field should be blank or empty yet it
forces us to have an erroneous date. When we import data we need to stuff
fields with that bogus date of 1900. I'm sure we have just missed something
so please point us in the correct direction.

Thank you!

Chris

Re: Dates and defaults Andrew J. Kelly
3/10/2005 12:00:07 AM
You can't have an empty datetime like you did in VFP. You need to allow
NULL's and store a NULL instead.

--
Andrew J. Kelly SQL MVP


[quoted text, click to view]

RE: Dates and defaults David Portas
3/10/2005 3:41:02 AM
Either set a default date (a fixed value or based on the the
CURRENT_TIMESTAMP) or allow the value to default to NULL. I don't understand
why you say you can't set a default for the date. What is the problem? Do you
get an error message?

Unlike VFP, SQL Server doesn't have a blank date other than NULL. That
shouldn't really be a problem. Is there some functionality you want that you
can't get from a NULL or another default date value?

--
David Portas
SQL Server MVP
--
AddThis Social Bookmark Button