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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

752 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