|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, September 28, 2010 2:33 PM
Points: 64,
Visits: 55
|
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Friday, January 11, 2013 12:41 PM
Points: 621,
Visits: 297
|
|
That was tricky one.
I didn't knew that when a number is casted to DATETIME, that number is added '1/1/1900' and returns the resulting date.
Bhavesh Patel
http://bhaveshgpatel.wordpress.com/
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Tuesday, July 05, 2011 8:18 AM
Points: 582,
Visits: 359
|
|
| Nice question... demonstrates how the subtraction operation implicitly casts the result as an integer data type thus avoiding the error message that '435365' on its own would have caused.
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 10:09 AM
Points: 648,
Visits: 684
|
|
A neat question, but since I didn't see a reason for any of the implicit conversions not to work, I assumed the one datetime value on the list had to be the correct answer. If there was another datetime option I probably would have had to guess.
----- a haiku...
NULL is not zero NULL is not an empty string NULL is the unknown
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 7:18 AM
Points: 478,
Visits: 1,260
|
|
This doesn't work in SQL Server 2005 TSQL , end up with an a Msg 1305...
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 10:09 AM
Points: 648,
Visits: 684
|
|
chrisn-585491 (11/18/2009) This doesn't work in SQL Server 2005 TSQL , end up with an a Msg 1305...
Works perfectly for me in 2005.
----- a haiku...
NULL is not zero NULL is not an empty string NULL is the unknown
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Tuesday, July 05, 2011 8:18 AM
Points: 582,
Visits: 359
|
|
chrisn-585491 (11/18/2009)
This doesn't work in SQL Server 2005 TSQL , end up with an a Msg 1305... 
worked for me in 2005
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 7:18 AM
Points: 478,
Visits: 1,260
|
|
 Restarted Management Studio and the results work now as expected...
|
|
|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 11:57 AM
Points: 708,
Visits: 660
|
|
| Interesting, I got this wrong because in Excel 434115 = July 24th 3088, not the 26th. Why there is a difference of 2 days over a 1100+ year gap is beyond me. Sum of leap minutes?
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, March 16, 2011 3:52 AM
Points: 288,
Visits: 105
|
|
Here is how i got it!!!
select dateadd("d",'435365'-1250, cast (0 as datetime))
Hiren
Hiren Shah
KISS (Keep It Simple Stupid)
|
|
|
|