| Author | Message | 
		
		  | bindu | 
			  
				|  Posted: Mon Oct 25, 2004 4:28 pm    Post subject: date subtraction |   |  | 
		
		  | Voyager
 
 
 Joined: 07 May 2004Posts: 97
 
 
 | 
			  
				| Hi, I want to subtract n number of days from the current date
 
 DECLARE DT DATE;
 DECLARE n INTEGER;
 SET n=10;
 SET OutputRoot.XML."xml"."date"= CURRENT_DATE - INTERVAL n DAY;
 
 then i am getting errors. Any suggestions.
 
 Thanx,
 Bindu.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kirani | 
			  
				|  Posted: Mon Oct 25, 2004 4:58 pm    Post subject: |   |  | 
		
		  | Jedi Knight
 
 
 Joined: 05 Sep 2001Posts: 3779
 Location: Torrance, CA, USA
 
 | 
			  
				| What is the exact error message you are getting? 
 Have you tried putting constant there? For example,
 
 SET OutputRoot.XML."xml"."date"= CURRENT_DATE - INTERVAL '10' DAY;
 _________________
 Kiran
 
 
 IBM Cert. Solution Designer & System Administrator - WBIMB V5
 IBM Cert. Solutions Expert - WMQI
 IBM Cert. Specialist - WMQI, MQSeries
 IBM Cert. Developer - MQSeries
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | RocknRambo | 
			  
				|  Posted: Mon Oct 25, 2004 4:59 pm    Post subject: |   |  | 
		
		  | Partisan
 
 
 Joined: 24 Sep 2003Posts: 355
 
 
 | 
			  
				| wat error ur getting...?? 
 in ur ESQL code
 i see there z no single quotes (probably a typo)..
 
 
 and if ur n of days is constant and try this..
 
 SET OutputRoot.XML."xml"."date"= CURRENT_DATE - INTERVAL '10' DAY;
 
 
 
 -RR
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | RocknRambo | 
			  
				|  Posted: Mon Oct 25, 2004 5:02 pm    Post subject: |   |  | 
		
		  | Partisan
 
 
 Joined: 24 Sep 2003Posts: 355
 
 
 | 
			  
				| oops!...if I see the timestamp... looks like it was coincidence tht me & kirani..had hit the submit in few seconds gap....   
 
 Sorry for repeatable answers
 
 -RR
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | bindu | 
			  
				|  Posted: Mon Oct 25, 2004 5:05 pm    Post subject: date subtraction urgent |   |  | 
		
		  | Voyager
 
 
 Joined: 07 May 2004Posts: 97
 
 
 | 
			  
				| Hi, Thanx for ur replies. But here N is not constant so its a varible. Any suggestions.
 
 Thanx ,
 Bindu
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kirani | 
			  
				|  Posted: Mon Oct 25, 2004 5:07 pm    Post subject: |   |  | 
		
		  | Jedi Knight
 
 
 Joined: 05 Sep 2001Posts: 3779
 Location: Torrance, CA, USA
 
 | 
			  
				| In your PM you mentioned that you get "syntax error". Can you provide your environment details? I'd suggest that you try deploying your message flow even if it says syntax error.
 _________________
 Kiran
 
 
 IBM Cert. Solution Designer & System Administrator - WBIMB V5
 IBM Cert. Solutions Expert - WMQI
 IBM Cert. Specialist - WMQI, MQSeries
 IBM Cert. Developer - MQSeries
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | bindu | 
			  
				|  Posted: Mon Oct 25, 2004 5:12 pm    Post subject: date subtraction urgent |   |  | 
		
		  | Voyager
 
 
 Joined: 07 May 2004Posts: 97
 
 
 | 
			  
				| Hi , SET OutputRoot.XML."xml"."Low"= CURRENT_DATE - INTERVAL lo DAY ;
 
 LO is INTEGER data type.
 
 BIP2403E: (61, 44) : An interval qualifier is not allowed here.
 
 An interval qualifier was specified after a pair of parentheses which did not contain a subtraction expression.
 
 Correct the syntax of your expression and redeploy the message flow.
 
 Thanq You,
 Bindu.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | JT | 
			  
				|  Posted: Mon Oct 25, 2004 5:14 pm    Post subject: |   |  | 
		
		  | Padawan
 
 
 Joined: 27 Mar 2003Posts: 1564
 Location: Hartford, CT.
 
 | 
			  
				| 
   
	| Code: |  
	| DECLARE n CHARACTER; SET n= '10';
 |  It appears the INTERVAL parameter is a string, not an integer. Click here for details.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | bindu | 
			  
				|  Posted: Mon Oct 25, 2004 5:24 pm    Post subject: date subtraction urgent |   |  | 
		
		  | Voyager
 
 
 Joined: 07 May 2004Posts: 97
 
 
 | 
			  
				| hI , 
 If i set n as character then i am getting the follwoing error on LOG
 
 BIP2402E: (60, 57) : Syntax error : 'integer lo'.
 
 The token caused a syntax error.
 
 Correct the syntax of your expression and redeploy the message flow.
 
 any suggestions,
 
 Thanx,
 Bindu.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kirani | 
			  
				|  Posted: Mon Oct 25, 2004 5:26 pm    Post subject: |   |  | 
		
		  | Jedi Knight
 
 
 Joined: 05 Sep 2001Posts: 3779
 Location: Torrance, CA, USA
 
 | 
			  
				| Well, in that case try using EVAL statement. _________________
 Kiran
 
 
 IBM Cert. Solution Designer & System Administrator - WBIMB V5
 IBM Cert. Solutions Expert - WMQI
 IBM Cert. Specialist - WMQI, MQSeries
 IBM Cert. Developer - MQSeries
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | bindu | 
			  
				|  Posted: Mon Oct 25, 2004 6:37 pm    Post subject: date subtraction |   |  | 
		
		  | Voyager
 
 
 Joined: 07 May 2004Posts: 97
 
 
 | 
			  
				| Hi kiran, can you tell me how can i use EVAL for this. Thanx for ur help.
 
 Thanx,
 Bindu.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | JT | 
			  
				|  Posted: Mon Oct 25, 2004 7:18 pm    Post subject: |   |  | 
		
		  | Padawan
 
 
 Joined: 27 Mar 2003Posts: 1564
 Location: Hartford, CT.
 
 | 
			  
				| 
   
	| Quote: |  
	| BIP2402E: (60, 57) : Syntax error : 'integer lo'. 
 The token caused a syntax error.
 
 Correct the syntax of your expression and redeploy the message flow.
 |  Can you post your latest ESQL code?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | bindu | 
			  
				|  Posted: Mon Oct 25, 2004 7:38 pm    Post subject: date subtraction |   |  | 
		
		  | Voyager
 
 
 Joined: 07 May 2004Posts: 97
 
 
 | 
			  
				| Hi, Actuvally i am looking for recent date among four dates(yyyy-mm-dd) so any suggestions for this.
 
 Thanx,
 Madhu
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kirani | 
			  
				|  Posted: Mon Oct 25, 2004 10:46 pm    Post subject: |   |  | 
		
		  | Jedi Knight
 
 
 Joined: 05 Sep 2001Posts: 3779
 Location: Torrance, CA, USA
 
 | 
			  
				| You can store your dates into Environment Variable and then use MAX (or MIN) function to find most recent/old date. For example, 
 
   
	| Code: |  
	| DECLARE D1 DATE CURRENT_DATE;
 DECLARE D2 DATE CURRENT_DATE;
 DECLARE D3 DATE;
 DECLARE D4 DATE;
 SET D3 = D1 + INTERVAL '10' DAY;
 SET D4 = D2 + INTERVAL '20' DAY;
 
 SET Environment.Variables.Dt[1] = D1;
 SET Environment.Variables.Dt[2] = D4;
 SET Environment.Variables.Dt[3] = D2;
 SET Environment.Variables.Dt[4] = D3;
 
 SET OutputRoot.XML.MyData.MaxDate = THE (SELECT  MAX(t) from Environment.Variables.Dt[] as t);
 
 |  
 This will return highest date.
 _________________
 Kiran
 
 
 IBM Cert. Solution Designer & System Administrator - WBIMB V5
 IBM Cert. Solutions Expert - WMQI
 IBM Cert. Specialist - WMQI, MQSeries
 IBM Cert. Developer - MQSeries
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kirani | 
			  
				|  Posted: Mon Oct 25, 2004 10:53 pm    Post subject: |   |  | 
		
		  | Jedi Knight
 
 
 Joined: 05 Sep 2001Posts: 3779
 Location: Torrance, CA, USA
 
 | 
			  
				| oh... and you can use EVAL function like this, 
 
   
	| Code: |  
	| DECLARE DY CHAR;
 SET DY = '10';
 SET D3 = D1 + EVAL('INTERVAL '''|| DY || ''' DAY');
 
 |  _________________
 Kiran
 
 
 IBM Cert. Solution Designer & System Administrator - WBIMB V5
 IBM Cert. Solutions Expert - WMQI
 IBM Cert. Specialist - WMQI, MQSeries
 IBM Cert. Developer - MQSeries
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |