Gaurav
Gaurav

Reputation: 2103

Date queries in monetdb?

I am able to do the following query

select (current_date-interval '1' day) ,a,b from (select '1' as a, 2 as b) as t2;

But I am not able to put variables in place of '1'. I have tried the following methods with no success

select (current_date-interval b day) ,a,b from (select '1' as a, 2 as b) as t2;
select (current_date-interval a day) ,a,b from (select '1' as a, 2 as b) as t2;

I have also tried casting but still no result.

Upvotes: 1

Views: 783

Answers (1)

Gaurav
Gaurav

Reputation: 2103

I found a solution to this:

select (current_date-interval 1 day*b) ,a,b from (select '1' as a, 2 as b) as t2;
select (current_date-interval 1 day*cast(a as int)) ,a,b from (select '1' as a, 2 as b) as t2;

So this question is answered :)

Upvotes: 1

Related Questions