I change OCI8 version for PHP and since this query dosn\'t work :
SELECT \'M\'||to_char(to_date(OD.DATE2,\'DD/MM/YYYY\'),\'MM\') PERIODE, count(*) DATA, OD.D
Looking at the line:
OD.DATE2 BETWEEN '08/03/2015' AND '08/03/2016'
Then '08/03/2015'
and '08/03/2016'
are string literals and are not dates.
Oracle will attempt an implicit conversion from a string literal to a date using your NLS_DATE_FORMAT
session parameter as the format mask and if this does not work it will throw an error.
The simple solution is not to use string literals but use date literals instead:
SELECT 'M'||to_char( DATE2, 'MM' ) PERIODE,
count(*) DATA,
DCCPT
FROM BDD
WHERE BDD = 'phone'
AND SENS = 'Ent'
AND DCCPT IN ( 'PIOLUC' )
AND DATE2 BETWEEN DATE '2015-03-08' AND DATE '2016-03-08'
GROUP BY
'M'||to_char( DATE2, 'MM' ),
DCCPT
But you could also specify the format mask:
OD.DATE2 BETWEEN TO_DATE( '08/03/2015', 'DD/MM/YYYY' ) AND TO_DATE( '08/03/2016', 'DD/MM/YYYY' )