Tuesday 24 January 2006

Cast vs Convert downunder

Kathi Kellenberger provides some pointers on converting in her Cast vs Convert post.


Being from down under my "converts" are usually,

SELECT CONVERT(varchar(12), GetDate(), 106)
------------
24 Jan 2006

and

SELECT CONVERT(varchar(30), GetDate(), 113)
------------------------------
24 Jan 2006 18:44:51:087

I find that using the character version of the month avoid any nastiness when different regional settings are involved.


Also, it should be noted that CAST is the ANSI/FIPS standard, probably why "CAST is usually preferred" ;)


No comments: