Search code examples
sql-serversql-server-2005typesdatetime2

Create datetime2 as custom datatype in SQL Server 2005


Many have come across the fact that SQL Server 2005 doesn't support datetime2. I was wondering if I can add it as a custom datatype instead.

I created a custom type with the name datetime2 so that's done.

Now I need to set the min date value, but is that even possible, since the custom type is based on the datetime type?


Solution

  • To get over this I changed the datatypes in the database to varchar. next I modified the stored procedure to do the conversion between the date entered in the search form and the values in the database. It's an ugly solution and I have to 'manually' compare year, month and day values, but it works in the end with a minimal effort. Customer happy, developer... on the fence :-)