var start = new Date();
var end = new Date(start.getFullYear(), start.getMonth(), start.getDate(), 23, 59, 59);
var maxReturnedRows = 100;
var query = 'SELECT id FROM table where date_field >= ? AND date_field <= ?';
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, new Array(start, end), maxReturnedRows);
Servoy generates this query:
used sql SELECT id FROM table WHERE date_field >= ? AND date_field <= ?
questiondata[0]= 2005-03-13 ,type: java.sql.Date
questiondata[1]= 2005-03-13 ,type: java.sql.Date
This query doesn’t care about the time portion of the query ?! Instead of “2005-03-13” I’d expect “2005-03-13 13:41:22” and “2005-03-13 23:59:59”
Why is this? The column is a datetime in MS SQL Server 2000.
used sql SELECT id FROM table WHERE date_field >= ? AND date_field <= ?
questiondata[0]= 2005-03-13 ,type: java.sql.Date
questiondata[1]= 2005-03-13 ,type: java.sql.Date
Yes, of course, I can manually create a date string. The problem with this is that some databases like it this way, some in another way. I’d prefer to let Servoy do it. The question is: why does it use a java.sql.Date without time portion?
and then use queryDate in the SQL-query I am getting the right results on an US English MS SQL Server. If I use the same query on a German SQL Server it doesn’t work (I am getting some arithmetic overflow error). Somehow this is understandable since the German date format differs from the US date format. Of course I could use a formatter with my query but that looks different on every database.
I was hoping if Servoy does the job the date gets formatted in the right way (and I think it is). But this is useless if I time portion is passed to the database if I want to.
Am I doing something wrong or is Servoy or is Microsoft?