Author |
Message
|
kumar.shanj |
Posted: Mon Jan 17, 2011 2:55 am Post subject: How to Adding a integer value to Date variable? |
|
|
Apprentice
Joined: 18 Nov 2010 Posts: 49
|
My requirement is to add some noOfDays to a Date variable in ESQL code of Compute node of Websphere Message broker.
When i am trying like
SELECT
CASE
WHEN
(cast(A.TERMINATION_DT as date FORMAT 'dd-mon-yy')
<= cast((CURRENT_DATE +1) as date FORMAT 'dd-mon-yy'))
THEN
A.TERMINATION_DT
ELSE
NULL
END AS EndDate
FROM
Database_VW AS A
I am getting a error like Invalid or incompatible data types for '+' operator. |
|
Back to top |
|
 |
mgk |
Posted: Mon Jan 17, 2011 3:07 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hello. Look at the INTERVAL datatype - you can declare an INTERVAL of a given number of DAYs.
Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
kumar.shanj |
Posted: Mon Jan 17, 2011 5:13 am Post subject: |
|
|
Apprentice
Joined: 18 Nov 2010 Posts: 49
|
But i need to find the difference between two dates and manupulation of date value by adding one day to the current date.
SELECT
CASE
WHEN
((A.TERMINATION_DT )
<= ((CURRENT_DATE +1 ) ) ) THEN
A.TERMINATION_DT
ELSE
NULL
END AS EndDate
FROM Database_VW AS A
Is there any way to add a number to a date variable to get output as date only? |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jan 17, 2011 5:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kumar.shanj wrote: |
Is there any way to add a number to a date variable to get output as date only? |
Yes. Look at the INTERVAL datatype  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kumar.shanj |
Posted: Mon Jan 17, 2011 10:09 am Post subject: |
|
|
Apprentice
Joined: 18 Nov 2010 Posts: 49
|
SET put_Date = CURRENT_DATE + CAST(1 AS INTERVAL DAY);
This code is working.
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jan 17, 2011 10:13 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kumar.shanj wrote: |
This code is working. |
Told you. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|