I need to use a date variable in a select
, like bellow, but I'm getting this error: Expected tokens may include: "". SQLSTATE=42601
How can use these variables in a shell script?
day0_T1=`TZ=CST+12 date +"%Y-%m-%d %T"`
day0_T0=`TZ=CST+24 date +"%Y-%m-%d %T"`
dayn_Tn=`TZ=CST+n date +"%Y-%m-%d %T"`
db2 connect to BD
db2 "/path/result.tmp OF DEL MODIFIED BY COLDEL; decplusblank striplzeros
select count(*),user from table1
and close_datetime between cast(date('$day0_T0') as timestamp) AND cast(date('$day0_T1') as timestamp)
and task = 'task1'
group by user
with ur"
db2 terminate
export
command itself.SELECT blah FROM table1 AND...
is a little odd. I would've expected aWHERE
clause instead of theAND
.