Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread current_date()-inteval cast(mydays as varchar) day ?
Tue, Apr 30 2019 3:54 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Is it possible to have something like this in sql:

select  current_date()-interval cast(mydays as varchar) day from mytable where mydays>0

Yusuf Zorlu
MicrotronX
Tue, Apr 30 2019 9:06 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Yusuf


Dunno - what happens if you try it?

Roy Lambert
Wed, May 1 2019 6:11 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Roy Lambert wrote:

<< Dunno - what happens if you try it?

with cast:
select  current_date()-interval cast(mydays as varchar) day from mytable where mydays>0

ElevateDB Error #700 An error was found in the statement at line 1 and column 33 (Expected interval constant but instead found cast)


without cast:
select  current_date()-interval mydays day from mytable where mydays>0

ElevateDB Error #700 An error was found in the statement at line 1 and column 33 (Expected interval constant but instead found mydays)


So it seems that the parameter for interval can't be another field. Any tricks to get this work?

Yusuf Zorlu
MicrotronX
Wed, May 1 2019 6:16 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Yusuf ,

What type is "mydays" ?

--
Fernando Dias
[Team Elevate]

Wed, May 1 2019 7:15 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Yusuf

I'm guessing from part of the statement that mydays is integer in which case

select current_Date - cast(mydays as interval day)  from mytable

should work. Wether it gives you what you want is something else though.

Roy Lambert
Thu, May 2 2019 4:04 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Roy Lambert wrote:

<< select current_Date - cast(mydays as interval day)  from mytable

<< should work. Wether it gives you what you want is something else though.

Thank you very much Roy, that query is working.
Sometimes we don't see the forest because of too much trees...
Yusuf Zorlu
MicrotronX
Image