Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

DateTime Precision Expand / Collapse
Author
Message
Posted Monday, November 28, 2011 9:12 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:53 AM
Points: 1,176, Visits: 778
tks all for the commentary today too!
Post #1212574
Posted Monday, November 28, 2011 9:25 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 10:21 AM
Points: 20,462, Visits: 14,089
Thanks for the ¿



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1212584
Posted Monday, November 28, 2011 11:00 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:46 AM
Points: 3,150, Visits: 1,900
Interesting question. Thanks!
Post #1212660
Posted Monday, November 28, 2011 11:05 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 8:55 AM
Points: 1,520, Visits: 3,035
Hugo Kornelis (11/28/2011)
roger.plowman (11/28/2011)
Using single quotes for both strings and dates is a brain-dead design decision--period.

Technically, T-SQL is not using single quotes for both strings and dates. It uses single quotes for strings only.
There is no way to have date literals in T-SQL; that's why we have to make do with string literals that will be converted (at execution time) to date or datetime values.

</pedantic>

Single quotes ARE for strings only, true. So the trouble comes from our getting used to implicit conversions and expecting them based on our human experience. As may have been noticed in the past, MS SQL is not human . We either have to remind ourselves to consider datatypes (as so many QODs do), or look for MS to require explicit conversion, either with a CAST/CONVERT or special delimiters as with the suggested pound-sign notation #2011-11-28#. If I'm voting, I say leave it as is and stay alert.
Post #1212665
Posted Monday, November 28, 2011 12:24 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, November 27, 2013 2:14 PM
Points: 341, Visits: 199
Guilty as charged. I fell for this in a production environment. It was a particularly difficult bug to find. I Did not recognize it was doing the implicit conversion as strings.

Cheers, J



Post #1212703
Posted Tuesday, November 29, 2011 3:10 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 2:25 PM
Points: 1,253, Visits: 13,546
good question!


rfr.ferrari
DBA - SQL Server 2008
MCITP | MCTS

remember is live or suffer twice!
Post #1213039
Posted Tuesday, November 29, 2011 4:44 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, August 21, 2012 1:15 AM
Points: 191, Visits: 224
Ouch, you got me, I assumed implicit conversion without thinking it through. Thanks for the question.

/@devandreas
Post #1213067
Posted Thursday, May 30, 2013 6:25 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, September 27, 2013 5:37 AM
Points: 306, Visits: 524
1+ for me

Neeraj Prasad Sharma
Sql Server Tutorials
Post #1458183
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse