request with timestamp

request with timestamp

Hello,

I have a problem when requesting my Supportcenter plus with postgresql
( 8.1.0 Build Number 8117 )

I have a bash script to bypass the problem :
On linux :

#### VARIABLE TIMESTAMP
midnight=$(date -d 'today 00:00:00' +"%s")
midnight2=$((($midnight) * 1000 ))

And then i tried to have all revolved tickets since midnight, today


"SELECT count(wo.WORKORDERID)
FROM WorkOrder wo
LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID
LEFT JOIN SDUser td ON wos.OWNERID=td.USERID
LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID
LEFT JOIN WorkOrder_Queue wo_queue ON wo.WORKORDERID=wo_queue.WORKORDERID
LEFT JOIN QueueDefinition queue ON wo_queue.QUEUEID=queue.QUEUEID
WHERE  ((ti.FIRST_NAME != 'Spam_n1')
OR (ti.FIRST_NAME::TEXT IS NULL))
AND (queue.QUEUENAME = 'SSE')
AND (((wo.RESOLVEDTIME >= $midnight2)
AND ((wo.RESOLVEDTIME != 0)
AND (wo.RESOLVEDTIME IS NOT NULL)))) AND (wo.DEPARTMENTID = 1) AND wo.ISPARENT='1'"


how could i have the good timestamp without setting up my variable "midnight*" ?

Thank you for your help.