hello, every one
i'm using ms sql server 2005 and i need to store date values partially
for example, the day part of a date may stay unknown in fact but mssql constrains to specify the full date like the follow:
INSERT foo(dt) VALUES('2001-10-31');
though i would like to use something like this:
INSERT foo(dt) VALUES ('2001-10-??');
of course, ms sql doesn't allow to do such expressions, and i've found a rough example that converts date parts into multipliers:
SET NOCOUNT ON
CREATE TABLE foo (
dt INT
)
INSERT foo VALUES (
DATEPART(YEAR, GETDATE()) * 10000
+ DATEPART(MONTH, GETDATE()) * 100
+ DATEPART(DAY, GETDATE())
)
SELECT dt FROM foo
DROP TABLE foo
... oooof, i can't believe if this is the only way to solve such problem, so i would like to ask: how can i solve this problem in the best way?
thank you for advices