Problem running sql query on sql express

Aleks used Ask the Experts™
I am running a query on a few servers, it works fine on all SQL 2008 R2 and up. But when I ran it on an SQL Express 2005 I got an error.

This is the query:

SELECT ExpiresOn as originalValue,
    CONVERT(VARCHAR(25), CONVERT(DATE, ExpiresOn), 101) as newValue
    FROM Users
    WHERE ISDATE(ExpiresOn) = 1

This is the error:

Type DATE is not a defined system type

Is there a way to tweak the sql above so it works on 2005 ?   Meantime Ill advice my client to update their SQL.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
The DATE data type was introduced to T-SQL with SQL Server 2008. So you cannot use it on SQL Server 2005 or lower.

So you need to convert it to DATETIME.

But upgrading is the better path.
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
... and there is no real reason for keeping 2005 Express but the effort (which is not that much).


I agree. I already asked the client to upgrade to 2008R2

I heard it also doesn't work on 2012  ?  Is this true ?
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

ste5anSenior Developer
Nope. The DATE data type still exists :)
Distinguished Expert 2017
Since you are advising the upgrade route,..

However, if you want to maintain the current query functionality no matter what system you are on, you could use sp_addtype to define DATE as the data type matching DATETIME.
Not sp_addtype defines a user datatype on the server


Thanks everyone !

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial