Hi,
I am having issues while trying to have a custom user input based variable into my SQL code. The problem with the database I am connecting is that the date column is character. So here is the actual code that works well with hard coded dates inside the SQL query.
Open Database("Generic database connection string",
" SELECT
p.productname,
p.model,
p.family,
TO_DATE (SUBSTR (txntime, 1, 15), 'yyyy/mm/dd hh24miss') txntime
FROM database p
WHERE
txntime >= '20161201 000000000'
AND txntime < '20161231 000000000'
",
// End of SQL statement
"New_Table" // New table name
);
The picture below shows the sample view on how the dates are saved in this table. Column property is Character & Nominal.
Here is the code I tried to insert user input variable. This code returns an empty table.
Delete Symbols();
Delete Globals();
nw = new window("Scrap Data", << modal(),
panelbox("Enter Date Range",
hlistbox(
text box("From Date"),
fromdate_teb = text edit box("%", << set width (100)),
),
hlistbox(
text box("To Date"),
todate_teb = text edit box("%" , << set width (100)),
),
),
panelbox("Actions",
hlistbox(
ok_button = button box("OK",
fromdate = fromdate_teb << get text;
todate = todate_teb << get text;
ok_pushed = 1;),
cancel_button = button box("Cancel", ok_pushed = 0),
)
)
);
Open Database("Generic database connection string",
" SELECT
p.productname,
p.model,
p.family,
TO_DATE (SUBSTR (txntime, 1, 15), 'yyyy/mm/dd hh24miss') txntime
FROM database p
WHERE
txntime >= '^fromdate^'
AND txntime < '^todate^'
",
// End of SQL statement
"New_Table" // New table name --> can be changed as per requirements
);