Question

  Asked: May 6 2008   3:26 PM GMT
  Asked by: Ctrevino


SQL DB2 COBOL date reformatting


COBOL, SQL, DB2

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

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



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
SELECT 
sentence you can use the
VARCHAR_FORMAT
scalar function to make your dates look as you want.
--
Juan Lanus
  • AddThis Social Bookmark Button

Browse more Questions and Answers on AS/400, Development and Database.

Looking for relevant AS/400 Whitepapers? Visit the Search400.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Sloopy  |   May 8 2008  8:26AM GMT

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.