February 15, 2008 at 9:07 am
Hello all,
I've recently started using MSSQL and am having problems selecting data from a table based on a datetime passed through a form.
This is the sql that I currently have. Like this I don't get an error but I also don't get any results back.
[Code]SELECT * FROM dbo.CLAIMS WHERE ClaimStatus = 'OPEN' AND RECEIVED >= 01/1/2003 AND RECEIVED <= 31/12/2008[/Code]
I've tried wrapping the dates in ', " and # but each time I do that I get an error. Any idea's on what I can do to fix this?
Thanks in advance.
February 15, 2008 at 9:28 am
SQL Server uses single quotes around both dates and strings, not like Access which uses the # sign.
One thought is that SQL Server does not recognize day first date syntax like you are trying.
Try this:
[Code]SELECT * FROM dbo.CLAIMS
WHERE ClaimStatus = 'OPEN'
AND RECEIVED >= '01/01/2003'
AND RECEIVED <= '12/31/2008'[/Code]
February 15, 2008 at 9:37 am
Hi Jeremy,
That fixed the problem for me.
Thank you very much for your help.
February 15, 2008 at 9:41 am
no problem. Thanks for the feedback.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply