IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need to subtract X hours from timestamp in where clause


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ankit Kumar Gupta

New User


Joined: 08 Jan 2011
Posts: 16
Location: India

PostPosted: Thu May 09, 2013 7:02 pm
Reply with quote

Hi,

I have to use a query in cobol code as shown below:

Code:

EXEC SQL                                                 
 SELECT COUNT(*)                                         
   INTO                                                 
        :WS-COUNT                                 
   FROM table1                                 
   WHERE LST_UPDT_DTTM <= CURRENT TIMESTAMP - :WS-X HOURS
END-EXEC                                                 


Earlier i was using like "- 8 HOURS" and it was working perfect. But now, requirement is to hour from dataset and so, need to subtract like shown above.

It is failing in bind with SQLCODE=-171 SQLSTATE=42815.

WS-X is defined as x(02) in program. Please suggest
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu May 09, 2013 7:25 pm
Reply with quote

Define it as 9(02) icon_cool.gif

you can't substract with X(02)
Back to top
View user's profile Send private message
Ankit Kumar Gupta

New User


Joined: 08 Jan 2011
Posts: 16
Location: India

PostPosted: Thu May 09, 2013 7:29 pm
Reply with quote

I have tried that... Current Timestamp is system defined as X(26)
Back to top
View user's profile Send private message
Ankit Kumar Gupta

New User


Joined: 08 Jan 2011
Posts: 16
Location: India

PostPosted: Thu May 09, 2013 7:31 pm
Reply with quote

when 9(02), it throws compilation error as 'UNDEFINED OR UNUSABLE HOST VARIABLE "WS-X" '
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu May 09, 2013 7:36 pm
Reply with quote

Apologise Define it as S9(04) COMP
Back to top
View user's profile Send private message
Ankit Kumar Gupta

New User


Joined: 08 Jan 2011
Posts: 16
Location: India

PostPosted: Thu May 09, 2013 7:49 pm
Reply with quote

It worked... THanks a much Pandora...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
No new posts Timestamp difference and its average ... DB2 11
No new posts To search DB2 table based on Conditio... DB2 1
No new posts After hours quick-fix support for IBM... Mainframe Jobs 0
Search our Forums:

Back to Top