Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To get previous day from date function

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Tue Sep 18, 2007 2:49 pm    Post subject: To get previous day from date function
Reply with quote

Hi,

I am retrieving current system date from the following syntax in COBOL:

Accept ws-date from date.

Now my requirement is to get yesterday's date.

So can you please tell me on how to get that.

Any kind of help will be really appreciated.

- Mohit
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Tue Sep 18, 2007 2:55 pm    Post subject:
Reply with quote

Easiest would be to subtract one from INTEGER-OF-DATE of the current date followed by DATE-OF-INTEGER....
Back to top
View user's profile Send private message
kgumraj2

New User


Joined: 01 Aug 2007
Posts: 42
Location: Hyderabad

PostPosted: Tue Sep 18, 2007 3:13 pm    Post subject:
Reply with quote

Hi,

If you use, db2 use
EXEC SQL
SELECT ( CURRENT DATE -1 DAY)
INTO :<wS-VAR>
FROM SYSIBM.SYSDUMMY1
END-EXEC.
Back to top
View user's profile Send private message
snehalpatel

New User


Joined: 13 Sep 2007
Posts: 37
Location: India

PostPosted: Tue Sep 18, 2007 5:22 pm    Post subject:
Reply with quote

CICS Guy wrote:
Easiest would be to subtract one from INTEGER-OF-DATE of the current date followed by DATE-OF-INTEGER....


I could not understand by 'subtract one from INTEGER-OF-DATE of the current date followed by DATE-OF-INTEGER' ..

Can you please give some more idea on this .
Back to top
View user's profile Send private message
kgumraj2

New User


Joined: 01 Aug 2007
Posts: 42
Location: Hyderabad

PostPosted: Tue Sep 18, 2007 5:43 pm    Post subject:
Reply with quote

Hi,
Please find following code that might be of some use.

Code:

This converts date into integer.

compute DIFFERENCE-OF-DATES =         
 (FUNCTION INTEGER-OF-DATE (DT1) -   1)

This converts interger into date
compute DATE-var =         
 (FUNCTION DATE-OF-INTEGER(DIFFERENCE-OF-DATES )


Thanks.
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Wed Sep 19, 2007 12:03 pm    Post subject:
Reply with quote

Thanks all for all the inputs.
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Fri Sep 21, 2007 3:13 pm    Post subject:
Reply with quote

Hi All,

I have one doubt,If you subtract one from date integer up to 2 of the month it will be okay, If it is 1st of month then if you subtract 1 from date it will becomes zero then your logic will not work.

we have take care of the year, month and the date integer too.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Fri Sep 21, 2007 4:58 pm    Post subject:
Reply with quote

Hi Bala,

Quote:
have one doubt,If you subtract one from date integer up to 2 of the month it will be okay, If it is 1st of month then if you subtract 1 from date it will becomes zero then your logic will not work.


It will work.Please go through it.

http://publib.boulder.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=/com.ibm.entcobol3.doc/rlinfidt.htm
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts What is the Extract Function in JCL dharmaraok JCL & VSAM 3 Wed Jun 14, 2017 9:12 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us