I have posted this on the MSSQL board but have not received any working solutions. Seeing as this is a fairly common query I would like to try an ANSI SQL solution.
tblA
===============
ID[int] | TheDate [datetime]
1 | 2006-04-06 11:25:58.920
2 | 2006-04-13 11:36:42.000
I was using the following to select all dates between 2 supplied dates. I would like to compare
results in format 103 ie dd/mm/yyyy
SELECT convert(varchar(30),TheDate,103)
FROM tblA
WHERE convert(varchar(30),TheDate,103) >= '06/04/2006'
AND convert(varchar(30),TheDate,103) <= '13/04/2006'
The shortcomings of this approach are evident when you use a date like '06/06/2006' as it still returns results from April
Bearing in mind that bad dates like 31/04/06 can be passed into any sql what is the best
way of accomplishing this?
Thanks for replies
tblA
===============
ID[int] | TheDate [datetime]
1 | 2006-04-06 11:25:58.920
2 | 2006-04-13 11:36:42.000
I was using the following to select all dates between 2 supplied dates. I would like to compare
results in format 103 ie dd/mm/yyyy
SELECT convert(varchar(30),TheDate,103)
FROM tblA
WHERE convert(varchar(30),TheDate,103) >= '06/04/2006'
AND convert(varchar(30),TheDate,103) <= '13/04/2006'
The shortcomings of this approach are evident when you use a date like '06/06/2006' as it still returns results from April
Bearing in mind that bad dates like 31/04/06 can be passed into any sql what is the best
way of accomplishing this?
Thanks for replies