Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Adding an INTERVAL to a date where the interval is a user-variable
Thu, Jan 5 2012 12:19 PMPermanent Link

Adam Brett

Orixa Systems

I am used to this:

 DateRequired + INTERVAL '2' HOUR

i.e. having a datefield & adding some extra hours / days etc.

However, I am having trouble formulating SQL to do the following:

SELECT
 ID,
 TableName,
 CAST('Maintenance DUE' as  CHAR(60)) as Title,
 CAST(M.DateRequired as TIMESTAMP) as DateStart,
 CAST(M.DateRequired + INTERVAL '''' + CAST(LabourHours as VARCHAR(3)) + '''' HOUR as TIMESTAMP) as DateEnd

FROM Maintenance M
LEFT JOIN Assets A ON M.AssetsID = A.ID

--

I want to generate a dataset which can display a record in a diary / timesheet component, a la outlook. Crucially this component (the dxScheduler) lays out all the events with different sizes depending on how long they last.

I could put in a static value like this:

 CAST(M.DateRequired + INTERVAL '4' HOUR as TIMESTAMP) as DateEnd

... but that doesn't cope well with different length tasks.

Is it possible to pass in a dynamic value to the INTERVAL using a variable from a table or elsewhere & if so how would I do this
Thu, Jan 5 2012 1:22 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam

Just tested this is EDBManager


select
_fkprojects,
_hidealarm + cast(_fkprojects as interval hour),
_hidealarm
from calls
where
_hidealarm is not null


MIght get you under way

Roy Lambert [Team Elevate]
Fri, Jan 6 2012 8:46 AMPermanent Link

Adam Brett

Orixa Systems

Thanks Roy.
Image