Apache OpenOffice (AOO) Bugzilla – Issue 72146
date conversion in macro SQL code
Last modified: 2013-02-24 21:08:22 UTC
Hi, problem with RC1 of OO 2.1: there is a problem with a date code in macro programming example for the SQL-Code: Select * FROM `table_x` WHERE `date1` ={D '2006-11-29'} AND `date2` = {D '2006- 11-29'} AND .... This SQL command is working in my MySQL database (as well in the native SQL Code and also as an OO query). If I use an "executeQuery" command in a macro code, the date code is converted. Now there are slashes "/" (... `date1` =#2006/ 11/29# ....) in the command, as a result there occures a runtime error in basic (syntax error in query). Also changing the language settings doesn´t change this.... Thank you for your help best regards sarotti
jsc -> fs: can you please verify or comment this issue
could you please attach a sample Basic script?
Sorry, I checked everything (also I changed to 2.1 RC2) and now the error is not reproducible. I made some tests, and maybe it is a (or my) mistake in declaration the variables. I made the experience that SQL Macro Code with a date (DIM xxx as Date) is criticel to use when you create a query. But when you use a date-string it´s easier. I wrote a small function to convert a date in the standard SQL string (using the command CDateToIso) and now it´s working fine. function function_Date_Convert(date_basis as string) '// this function converts a date in a usable SQL date Dateconv=CDateToIso(date_basis) sYear=left(Dateconv, 4) sDay=right(Dateconv, 2) sMonth=mid(Dateconv,5,2) function_Date_Convert=sYear + "-" + sMonth + "-" + sDay end function Using this the date format is independent on the language code and it´s easier to handle. Now it´s possible to use it like this: .... sDate="01.01.2006" sDate=function_Date_Convert(sDate) sSQL="SELECT * FROM `table1` WHERE `Datefield` = #" + sDate + "'" resultSet=executeQuery(sSQL) ..... So, think it´s solved now Thank you for your cooperation sarotti
-> close