Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Format 6-Character Date Field For DB2

Posted on 2003-03-28
Medium Priority
Last Modified: 2010-04-15
I'm reading in a file and I have a six character date field coming in like this:  060299
so, it's month day year format.
I know I need a y2k check so I can add 20 or 19 to my year field.

But does anyone have a good function to format the rest of my string.

I think db2 expects the date in this format: '0001-01-01-'
for date and timestamp.

Thanks in Advance.
Question by:jtrapat1
1 Comment

Accepted Solution

Kocil earned 500 total points
ID: 8228434
To read the date
int y,m,d;

FILE *f;
f = fopen("DATE.TXT", "r");

fscanf(f, %2i%2i%2i,&d,&m,&y);

// asuume the border it 1980
y += (y > 80) ? 1900 : 2000;

print it

printf("%04d-%02d-%02d", y, m, d);


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question