Date and Time Conversion from Simple Numeric Fields

We have just started using Crystal Report 9.0 interfacing data using IBM Client Access ODBC for AS400 DB2. We have defined date and time field in simple numeric field such as 20060403 and 1200 for 04/03/06 and 12:00AM respectively.  We would like to show the date and time in converted manner at Crystal Report.  Is there any simple conversion technique to print them without changing AS400 database format?
Please advise me.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There is no simple conversion from CR that suit your format, but you could create a formula to achieve this, this is my example:

numbervar theDate := 20060403;
numbervar theTime := 1200;
stringvar strDate;
stringvar strTime;
numbervar theYear;
numbervar theMonth;
numbervar theDay;
numbervar theHour;
numbervar theMin;

strDate := TOTEXT(theDate,0,"");
strTime := TOTEXT(theTime,0,"");

theYear := TONUMBER(LEFT(strDate, 4));
theMonth := TONUMBER(MID(strDate, 5, 2));
theDay := TONUMBER(RIGHT(strDate, 2));
theHour := TONUMBER(LEFT(strTime, 2));
theMin := TONUMBER(RIGHT(strTime, 2));

CDATETIME(theYear, theMonth, theDay, theHour, theMin, 0);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

Another way would be to use this formula field:

to TEST display of the date field using a hard-coded variable:

Local StringVar myDate := "20060403";

to use your date field the syntax would be:


janmarini's suggestion is better ;)

glad I could help~

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.