The following code doesn’t appear to run when executed by code:
Stored procedure snippet:
AND (@month_ref = 81201
AND tsks.grouping_ref = @grouping_ref
AND ts.start_dtm BETWEEN convert(datetime, '2011-11-28')
AND convert(datetime,'2012-01-01')
)
OR (@month_ref = 81202
AND tsks.grouping_ref = @grouping_ref
AND ts.start_dtm BETWEEN convert(datetime,'2012-01-02')
AND convert(datetime,'2012-01-29')
)...
Server setup:
SQL Server is setup as:
- Language: English (United States)
And Windows Server region and language are set to:
- English (United States)
Our test server is set up for British English and the stored procedure appears to work just fine. I have a feeling the customer setup doesn’t like the dates.
DB design / data
ts.start_dtm looks like this in the database:
-
datatype – datetime
2011-04-01 00:00:00.000
So its setup as – YEAR | MONTH | DATE
My stored procedure is hardcoding the start_dtm as '2012-01-02' which is also in the same format.
Can you help me please?
The problem is the website fails when it tries to run the stored Procedure. The issue was the data conversion. I had to assign the format of date conversion.
You shouldn’t need an explicit conversion on the dates at all. This is ISO8601 format, so the database should understand it straight off:
If you need to convert them, specify what format you are using for the strings: