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

DATETIME VARIABLE BEHAVES STRANGE Expand / Collapse
Author
Message
Posted Thursday, May 22, 2008 12:33 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, May 1, 2012 1:35 AM
Points: 70, Visits: 67
/*
Sanjay S -- Jaipur, India
Is this a bug in SQL date Comparision or is there any logical reason
if there is a difference of .001 milisecond then datetime variable comparison behaves strange
*/
Declare @dt1 datetime, @dt2 datetime
set @dt1 = '2008-05-22 11:20:56.079'
set @dt2 = '2008-05-22 11:20:56.080'
if @dt2 <= @dt1
print '1>>> True date comparision1'
set @dt1 = '2008-05-22 11:20:56.078'
set @dt2 = '2008-05-22 11:20:56.079'
if @dt2 <= @dt1
print '2>>> True date comparision2'
if '2008-05-22 11:20:56.080' <= '2008-05-22 11:20:56.079'
print '3>>> True Str comparision1'
if '2008-05-22 11:20:56.079' <= '2008-05-22 11:20:56.078'
print '4>>> True Str comparision2'

/***********************************************
--And here goes the Result
***********************************************

1>>> True date comparision




***********************************************
--Can any body explain this strange result ??
***********************************************/
Post #505004
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse