First of all, many thanks for the tool! It's excellent!
I'm having a little issue, which I hope you can help with.
We have version 1.1.4 installed using a MSSSQL server 2008 database.
I have an attrbute "closed date" which displays as dd-mm-yyyy hh:mm in the interface, which is correct according to our default date format.
However, when I sort this column for a view, it is causing an error when it finds a date which cannot be a US format date (such as 14-02-2016)
This is stored as attr_value = '2016-02-14' in the attr_values table
I've done some digging and our SQL server still has the default language setting, so
SELECT CAST ('2016-02-14' as datetime) fails
whereas
SELECT CAST ('2016-14-02' as datetime) results in 2016-02-14 00:00:00.000
I can get around this failing by sending
set dateformat ymd
SELECT CAST ('2016-02-14' as datetime)
or alternatively
SELECT convert(datetime, '2016-02-14',101)
Although it would make sense to change the local/language of our SQL server to British (as we are in Australia we use the same date format) I am reluctant to do this as there are a number of other applications using the database and I don't want to inadvertently break one of them.
Unfortunately your app is using the CAST method, and I cannot find where to hack this to send a dateformat request.
Would appreciate any assistance you can offer.
- Log in to post comments
You can modify the castExpression() function in system/db/mssql/engine.inc.php to replace the cast() function with convert().
Regards,
Michał
Thanks for that. Definitely on the right track, but having changed the code to:
I'm seeing the following in SQL Profiler:
so it's throwing a couple of extra DESC keywords in. This appears when I change to the view where the date is sorted in descending order.
A simple hack would be to remove the spaces after commas:
CONVERT(datetime,$expression,101)
, then the code which inserts DESC won't recognize it as separate statements.Regards,
Michał
Many thanks. That seems to have fixed it.
Hi there,
Sorry to re-open this, but we are now having another datetime issue and I felt it would be helpful to reference this previous discussion.
So we now wish to create a view such as Requested Date < [Today]
The SQL generated is
But this is throwing an error
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.