Can I have some SQL tech support please?
Aug. 9th, 2006 04:49 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I'll start with a disclaimer: I am not very good at SQL. I don't use it much.
So, can anyone tell me why the following query isn't working?
USE [DATABASE]
GO
SELECT *
FROM [TABLE]
WHERE [DATETIME FIELD] BETWEEN [FIRST DATE] AND [LAST DATE]
GO
SQL accepts and runs the query but brings back zero results even though I know there are records that should fall into the range. I note that the display of the datetime field in Enterprise Manager is dd/mm/yyyy and that in a Query Result Pane it is yyyy-mm-dd. I have tried both of these, but no success. The exact same query runs fine on a numeric field, so my syntax is OK. What am I doing wrong?
So, can anyone tell me why the following query isn't working?
USE [DATABASE]
GO
SELECT *
FROM [TABLE]
WHERE [DATETIME FIELD] BETWEEN [FIRST DATE] AND [LAST DATE]
GO
SQL accepts and runs the query but brings back zero results even though I know there are records that should fall into the range. I note that the display of the datetime field in Enterprise Manager is dd/mm/yyyy and that in a Query Result Pane it is yyyy-mm-dd. I have tried both of these, but no success. The exact same query runs fine on a numeric field, so my syntax is OK. What am I doing wrong?
no subject
Date: 2006-08-09 04:08 pm (UTC)(no subject)
From:Have you fixed it?
Date: 2006-08-30 11:30 am (UTC)In my case it was to do with the date format - I had to output the date in ODBC format, then analyze it. My solution wouldn't solve your problem (as it was in Cold Fusion based code calling data from SQL server) but I recommend pursuing the date format angle if you haven't solved it already!
Apologies for inappropriate spamming if this is no use to you.
Re: Have you fixed it?
From: