SQL DB2 COBOL date reformatting

10 pts.
Tags:
COBOL
DB2
SQL
Hi and thanks in advance, I want to use DB2 SQL in COBOL to reformat a date from CCYY-MM-DD to MM-DD-YY. What is the simplest and most efficient way to do this? Christy
ASKED: May 6, 2008  3:26 PM
UPDATED: July 17, 2008  3:06 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

hi CTrevino,
The data in a date column in DB2 will always have the 4-digit year. This is intrinsic to the internal date format and you can not change it. Unless the dates were stored in varchar columns …
When you select the data then you can get the dates in different formats, or massage them at will.
In the <pre>SELECT </pre>sentence you can use the <pre>VARCHAR_FORMAT</pre> scalar function to make your dates look as you want.

Juan Lanus

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Sloopy
    I hope this does not sound like a stupid question, but are you intending only to use the embedded SQL to reformat dates? If so, then this is overkill. I ask this because I saw a tip somewhere recently where it was recommended to use embedded SQL to reformat dates. This is OK if you were going to use SQL ANYWAY, but not if it's the only thing you want to use it for. Otherwise, there are lots of ways to reformat a date within the COBOL language.
    2,195 pointsBadges:
    report
  • Skmcm
    That would be very helpful for me. I am getting a date from DB2 and I need to reformat it in COBOL. It will eventually be used in DOC1 so I need it to look like a date (i.e. with slashes or dashes). DOC1 was not recognizing the date I am passing in because right now it is just a numerical string, so I could not cast it as a date in DOC1. Ideally, I need it to look like 17-Jul-2008 to pass into DOC1. Can you help?
    40 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following