The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,779 other followers

SQL Server: learned that you can pass a Style to CAST and CONVERT (Transact-SQL)

Posted by jpluimers on 2014/03/19

Funny way to learn something new:

I hardly use CAST and CONVERT (Transact-SQL), and when I do, it is the standard SQL-92 way.

But a while ago, I came across some code like this:

CONVERT(DATETIME, "31/12/2013", 105);

and wondered what the 105 was.

And it appeared to convert from the Italian date format to DateTime. And that it has been there since at least SQL Server 2000, probably earlier.

Not sure why the passed slashes (/) in stead of dashes (-) as separators though.

There are styles for these groups of conversions:

  • Binary
  • Date/Time
  • Float/Real
  • Money/Smallmoney
  • XML

Never to old to learn something new (:

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: