Hi all,
I have a problem with a query on a Datetime field.
pls go thorugh the details.
Table name - HOLIDAYLIST
Fields in table.
1. HolidayName (varchar)
2. HolidayDate (Datetime)
Data in table (only one row is present)
'My Holiday', 04/01/2001:00:00:00:00 (take it as dd-mm-yyyy)
Query
---
SELECT * FROM HolidayList
WHERE CONVERT(VARCHAR(12), HolidayDate, 105)
BETWEEN '05-12-2000' AND '11-01-2001'
Problem
------
The above query is not returning any rows, though 4-1-2001
falls in the given range.
Obeservation
----------
If you give the day (of the start date) any value
from 01 to 04, (eg: 01-12-2000 instead of 05-12-2000)
the query fetches the row with the date 04-01-2001
Could you please tell me what is wrong with this query and what is the correct way of doing it?
Thanx in advance,
Boby.
I have a problem with a query on a Datetime field.
pls go thorugh the details.
Table name - HOLIDAYLIST
Fields in table.
1. HolidayName (varchar)
2. HolidayDate (Datetime)
Data in table (only one row is present)
'My Holiday', 04/01/2001:00:00:00:00 (take it as dd-mm-yyyy)
Query
---
SELECT * FROM HolidayList
WHERE CONVERT(VARCHAR(12), HolidayDate, 105)
BETWEEN '05-12-2000' AND '11-01-2001'
Problem
------
The above query is not returning any rows, though 4-1-2001
falls in the given range.
Obeservation
----------
If you give the day (of the start date) any value
from 01 to 04, (eg: 01-12-2000 instead of 05-12-2000)
the query fetches the row with the date 04-01-2001
Could you please tell me what is wrong with this query and what is the correct way of doing it?
Thanx in advance,
Boby.