Paul said:
How do I set-up a DD/MM/YY date field so that I can put a default value in
for the Year ?
The most relevant data type would be DATETIME, so the format would be
more like yyyy-mm-dd- hh:mm:ss (although I've heard said it's a
FLOAT/Double under the covers). You can ignore the time element and
hope/trust no one will put time elements in the database but a better
approach is to code appropriately using date functions: DATADD,
DATEDIFF, etc. If you store your date values as TEXT you will have to
do a lot more work.
A DEFAULT only takes affect when a row is first INSERTed. You will need
to choose the dd-mm element for your default value (TEXT data types
aside). You could use a CHECK constraint to enforce a year, unlike a
DEFAULT, a CHECK additionally bites on UPDATE.
Here's a bit of DDL I use often:
ALTER TABLE MyTable ADD effective_date DATETIME DEFAULT NOW() NOT
NULL;
And another:
ALTER TABLE MyTable ADD CONSTRAINT always_current CHECK
(effective_date = NOW());
Jamie.
--