Don't you just hate replying to your own post...
SOLVED
I solved the above mentioned by using parameters in the SQL query
SELECT "time", "value" FROM "piarchive".."picalc" WHERE expr = '''TAG1'' + ''TAG2''' and time BETWEEN ? and ? AND timestep='1d'
I then assign default values to these parameters.
NEXT PROBLEM
I need to extract data from multiple tables, but the timestamps of these table are different
The query below will give me the data I need from one table (pirange)
SELECT a.time,a.value as "123",
b.value as "234",
c.value as "345"
FROM piarchive..pirange a
INNER JOIN piarchive..pirange b
ON b.time = a.time
AND b.timestep = a.timestep
INNER JOIN piarchive..pirange c
ON c.time = a.time
AND c.timestep = a.timestep
WHERE a.tag =TAG1'
AND b.tag='TAG2'
AND c.tag='TAG3'
AND a.time BETWEEN '02-jan-2012 06:00' and 't+6h'
AND a.timestep = '1w'
order by a.time desc
PROBLEM
I want to use the same query above but get data from piarchive..pitotal using a different time period (1day extra to be exact)
SELECT a.time,a.value as "123",
b.value as "234",
c.value as "345",
d.value as "456"
FROM piarchive..pirange a
INNER JOIN piarchive..pirange b
ON b.time = a.time
AND b.timestep = a.timestep
INNER JOIN piarchive..pirange c
ON c.time = a.time
AND c.timestep = a.timestep
INNER JOIN piarchive..pitotal d
ON d.time BETWEEN '03-jan-2012 06:00' and 't+6h' --ALL KINDS OF HELL BROKE LOOSE FROM HERE
--AND d.timestep = a.timestep
WHERE a.tag ='TAG1'
AND b.tag='TAG2'
AND c.tag='TAG3'
AND d.tag='NEWTAG'
AND a.time BETWEEN '02-jan-2012 06:00' and 't+6h'
--AND d.time BETWEEN '03-jan-2012 06:00' and 't+6h'
--AND d.calcbasis = 'EventWeighted'
AND a.timestep = '1w'
order by a.time desc