View previous topic :: View next topic
|
Author |
Message |
venktv
New User
Joined: 29 Mar 2006 Posts: 59 Location: Montreal
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
venktv
New User
Joined: 29 Mar 2006 Posts: 59 Location: Montreal
|
|
|
|
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 |
|
|
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
|
|
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 |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
You can get date and using time CURRENT DATE and CURRENT TIME functions. |
|
Back to top |
|
|
venktv
New User
Joined: 29 Mar 2006 Posts: 59 Location: Montreal
|
|
|
|
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 |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Venkat,
If I remember correctly,
Date format - mm/dd/yyyy
Time format - hh.mi.ss.nnnnnn
in COBOl from DB2 fetch. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
If you fecth data from DB2,
Date format would be - YYYY-MM-DD
and TIME format would be HH-MM-SS. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
venktv
New User
Joined: 29 Mar 2006 Posts: 59 Location: Montreal
|
|
|
|
Friends,
Thanks very much for the replies..it really helped me to find the solution..
THANK YOU..
Venkat |
|
Back to top |
|
|
|