I'm trying to concatenate dates with other Sql statements so I can place common Where statements in 1 procedure.
I am running into troubles with the date.
What is happening is To and From dates are in format dd-mm-yyyy as in 10-01-2008
When I concatenate into v_SQL which is varchar2 it becomes dd-MONth- YY as in 10-JAN-08
Can somebody please explain why and how to fix?
-- v_inputdate is varchar2
-- Input Date
If Length(v_InputDate) > 0 Then
-- Date that is input is 10th January 2008
v_FromDate := To_Date(v_InputDate,'dd-mm-yyyy');
-- I am now 10-01-2008
If v_ReportType = 'D' Then
v_ToDate := v_FromDate + 1 ;
-- I am now 11-01-2008
If v_WhereSet = 1 Then
v_strTmp := ' AND ';
v_WhereSet := 1;
v_strTmp := ' WHERE ';
v_SQL := v_SQL || v_strTmp || ' pr.pres_dt >= ' || v_FromDate ||
' AND pr.pres_dt < ' || v_ToDate;
-- At this point v_SQL changes to have v_FromDate as 10-JAN-08
-- My data is stored as dd-mm-yyyy.