Does it make any sense to store just a year in the new Date SQL type in SQL 2008? My boss wanted this but we’re prompting the customer to enter year optional in a web form..just 4 integers. I don’t see why we’d use Date datatype as that also includes day and month and I’ve already got those seperated out into int fields in our DB table.
Year is optional on our web form, so if they only enter Month and Day, it makese no sense to me to store this in a date type of field because year will have to be something abritrary. I guess we could do 01-16-1900 if they didn’t enter year and then we’d have just day and month..but whatever, to me that’s a hack. I’d rather seperate all 3 into seperate fields only because we have one of those values (year) as optional. I don’t see that we’ll ever require year because it’s for a birthdate and we already discussed that would piss off customers if we required year anyway.
No, This makes no sense. It will result in more space in the database, and will also add unnecessarily any code where you are just looking for the year. You’ll have to use DatePart() in each query or extract the year in code. Either approach hurts performance.
But if your boss told you to do it, then you should probably do it. I wouldn’t make an issue of it. What’s your boss’s reasoning?
Correction
I retract the portion of the answer above that says “more space in the database”. The performance savings I was referring to are in the conversion to query by year.