|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
comparing dates
i am using sql server ver 7
i am trying to do select * from independent_investment_certificate_temp where independent_investment_certificate_temp.ticker_key = 31 and convert(varchar(40), cast(independent_investment_certificate_temp.maturity_date AS datetime),107) > convert(varchar(40), cast('2006-12-10 10:29:50.733' AS datetime),107) independent_investment_certificate_temp.maturity_date value is '2005-01-21 00:00:00.000' the query above returns a value even though '2005-01-21 00:00:00.000' is clearly < '2006-12-10 10:29:50.733' but why can anyone plz explain.. how can i compare dates stripping tyhem of the time so that all dates on the same day will be equivalent regardless of the time ![]() |
|
#2
|
||||
|
||||
|
the answer is because you are using style 107
convert(varchar(40), cast('2005-01-21 00:00:00.000' AS datetime),107) is Jan 21, 2005 convert(varchar(40), cast('2006-12-10 10:29:50.733' AS datetime),107) is Dec 10, 2006 'Dec' is less than 'Jan' QED ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > comparing dates |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|