Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Date fields in filters
Sat, Oct 6 2012 7:00 AMPermanent Link

Colin Wood

VirtualTec P/L

Could someone please guide me in the right direction... I've created a table filter that needs to display any records which are due to finish, a day prior to the planned finish date.  The syntax is incorrect when it reaches "- 1"  but I'm not sure how to correct it.

   Filter := '((PlannedFinish - 1) <= Current_Timestamp) and (Current_Timestamp < PlannedFinish)';

Any help appreciated.
Colin
Sat, Oct 6 2012 8:36 AMPermanent Link

Uli Becker

Colin,

> Could someone please guide me in the right direction... I've created a table filter that needs to display any records which are due to finish, a day prior to the planned finish date.  The syntax is incorrect when it reaches "- 1"  but I'm not sure how to correct it.
>
>      Filter := '((PlannedFinish - 1) <= Current_Timestamp) and (Current_Timestamp < PlannedFinish)';

You have to use intervals to calculate with dates and timestamps.

Using SQL (filter should be the same), try this:

select * from MyTable
where PlannedFinish >= Current_Timestamp - INTERVAL '1' DAY

Please note the quotes around "1".

Have a look at the manual (search for "interval types"). You'll find
some useful information there, e.g.:

<<

-- This example specifies a YEAR interval literal

SELECT * FROM Orders
WHERE (OrderDate + INTERVAL '1' YEAR) BETWEEN
DATE '2006-01-01' AND DATE '2006-01-31'

-- This example specifies a DAY interval literal

SELECT * FROM Orders
WHERE (ShipDate - OrderDate) > INTERVAL '2' DAY

-- This example specifies an HOUR interval literal

SELECT * FROM TimeClockEntries
WHERE (PunchOutTime - PunchInTime) > INTERVAL '8' HOUR

>>

Uli


Sat, Oct 6 2012 8:59 AMPermanent Link

Colin Wood

VirtualTec P/L

Thanks Uli, that did the trick.  I'll have another look through the manual too Smile
Col
Image