iTP Active Transaction Pages (iTP ATP) Programmer's Guide
ATP Objects, Properties, and Methods
iTP Active Transaction Pages (iTP ATP) Programmer’s Guide—522292-002
4-22
atp.SQL Object
Date and Time in SQL Statements
If you express the date and time as a literal in an SQL statement, you must also 
explicitly include the type—for instance, year to day—in the statement. However, if you 
express the data and time as a variable in the SQL statement, you must not explicitly 
include the type. The code fragment in Example 4-1
 demonstrates these rules:
Example 4-1. Date and Time in SQL Statements
atp.print (‘********************************************\n’);
tran = new atp.transaction();
//Date time value as a literal
s1 = new atp.SQL(
 "select tran.accountid,tran.tran_date,tran.tran_amount,"
 +"tran.tran_origin"
 +"from \\ATX.$DATA02.DJCANTA3.TRAN tran"
 +"where tran.tran_date > datetime '1995-07-31' year to day"
 +"for stable access"
 );
SQLError (s1,tran);
s1.execute(tran);
SQLError (s1,tran);
while (s1.next(tran)) {
 atp.print (s1.column_value,'\n');
 }
SQLError (s1,tran);
atp.print (‘********************************************\n’);
//Date time value as a variable
s2 = new atp.SQL(
 "select tran.accountid,tran.tran_date,tran.tran_amount,"
 +"tran.tran_origin"
 +"from \\ATX.$DATA02.DJCANTA3.TRAN tran"
 +"where tran.tran_date > ?START_DATE"
 +"for stable access"
 );
SQLError (s2,tran);
s2.execute('1995-07-31', tran);
SQLError (s2,tran);
while (s2.next(tran)) {
 atp.print (s2.column_value,'\n');
 }
SQLError (s2,tran);
tran.commit();










