Reputation: 1904
I am using the following query to list these records between specified dates.But ,it's not working.Also,don't gives me error.Just is coming blank screen.it's has column name. Any problem the following query?
SET DATEFORMAT dmy
select *from tamirarizakaydi where tarih between '31.01.2011 ' and ' 04.02.2011'
thanks in advance.
Upvotes: 1
Views: 69
Reputation: 452977
The leading and trailing spaces don't make any difference as far as I can see.
SET DATEFORMAT dmy
select CAST('31.01.2011 ' as date) , CAST(' 04.02.2011' as date), CAST('31.01.2011 ' as datetime), CAST(' 04.02.2011' as datetime)
Returns
---------- ---------- ----------------------- -----------------------
2011-01-31 2011-02-04 2011-01-31 00:00:00.000 2011-02-04 00:00:00.000
I'm going to guess that tarih
is stored as a string or you don't have any matching rows.
If tarih
is a character based column then your query will be doing a lexicographic comparison and look for rows where tarih >= '31.01.2011 ' and 'tarih <= ' 04.02.2011'
No rows can match this condition as the end of the range is alphabetically before the start of the range.
Upvotes: 2