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
 

 

DB2 Date and time

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
venktv

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Mon Mar 10, 2008 4:54 pm    Post subject: DB2 Date and time
Reply with quote

Hi All,

My qs is : How to get the DB2 DATE and TIME in COBOL program? I want to write it to a file in cobol pgm.

Thanks

venkat
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Mar 10, 2008 5:55 pm    Post subject: Re: DB2 Date and time
Reply with quote

venktv wrote:
Hi All,

My qs is : How to get the DB2 DATE and TIME in COBOL program? I want to write it to a file in cobol pgm.

Thanks

venkat


01 ws-date-time pic x(26).


EXEC SQL SET :WS-DATE-TIME = CURRENT TIMESTAMP END-EXEC.
Back to top
View user's profile Send private message
venktv

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Tue Mar 11, 2008 9:02 am    Post subject:
Reply with quote

Hi Craq,

Thanks very much for the reply,

Can I get DATE and TIME separately?

I want to populate two variables, one with DATE and another with TIME.

Thanks in advance
Venkat
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Tue Mar 11, 2008 10:10 am    Post subject:
Reply with quote

WS-DATE-TIME will have a value like 2008-03-10-21.36.50.960778, Take the first 10 digits for date(WS-DATE-TIME (1:10)) and remaining digits for time depending on whether u need which all parts(hours seconds etc..)..Or else you can use CURRENT TIME and CURRENT DATE fuction as in previous post..

Thanks,
Prajesh
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Tue Mar 11, 2008 11:42 am    Post subject:
Reply with quote

You can get date and using time CURRENT DATE and CURRENT TIME functions.
Back to top
View user's profile Send private message
venktv

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Tue Mar 11, 2008 11:44 am    Post subject:
Reply with quote

Hi Prajesh,

Thanks very much for info..

Just i would like to know the format of date and time reurned by CURRENT DATE and CURRENT TIME.

if u have info..pls share with me..

Thanks in advance
Venkat
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 788
Location: Chennai, India

PostPosted: Tue Mar 11, 2008 2:14 pm    Post subject:
Reply with quote

Venkat,

If I remember correctly,

Date format - mm/dd/yyyy
Time format - hh.mi.ss.nnnnnn

in COBOl from DB2 fetch.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Tue Mar 11, 2008 3:05 pm    Post subject:
Reply with quote

If you fecth data from DB2,

Date format would be - YYYY-MM-DD

and TIME format would be HH-MM-SS.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Tue Mar 11, 2008 3:44 pm    Post subject:
Reply with quote

keep in mind your default date return is based on your iso settings in your db2 system. you can always cast a date to a different format with the ISO keyword.

dates, times, timestamps are normally retrieved from db2 with SET keyword, although you can select from sysdummy1.
Back to top
View user's profile Send private message
venktv

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Tue Mar 11, 2008 4:12 pm    Post subject:
Reply with quote

Friends,

Thanks very much for the replies..it really helped me to find the solution..

THANK YOU..

Venkat
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 3 Sat May 06, 2017 12:59 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts Application not run by time HH:MM tri... jzhardy IBM Tools 1 Sun Apr 09, 2017 3:22 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm


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