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

DB2 Date and time


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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: 355
Location: New York

PostPosted: Tue Mar 11, 2008 11:42 am
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
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: 792
Location: Chennai, India

PostPosted: Tue Mar 11, 2008 2:14 pm
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: 355
Location: New York

PostPosted: Tue Mar 11, 2008 3:05 pm
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: 6966
Location: porcelain throne

PostPosted: Tue Mar 11, 2008 3:44 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top