Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format Conversion 1

Status
Not open for further replies.

zupnik

Technical User
Sep 21, 2004
28
US
Hi all,

My Specs:
CR - 8.5
DB - DB2 AS400

The Date (Number Format) I get from the AS400 is: 200,408.19
The way it should display in CR is 081904 as a dateformat.

appreciate all the help

thx
 
Try this formula:

numbervar dt := 200408.19;
totext(Date(Int(dt/100), Int(dt) mod 100, (dt * 100) mod 100), "MMddyy");

-dave
 
Dave,

thx for the replay

works correct... however

The date field should be 'flexible'.... now it returns 081904 for all dates..

For the AS400 number format 20,040,819.00 I used the following formula:

//If {ART_Consumed_by_reason.IDDLM}=0 then Date(1900,01,01) else


//DATE
//(
//(tonumber((left(totext({ART_Consumed_by_reason.IDDLM}),2)&mid(totext({ART_Consumed_by_reason.IDDLM}),4,2)))),
//(tonumber((mid(totext({ART_Consumed_by_reason.IDDLM}),6,1)&mid(totext({ART_Consumed_by_reason.IDDLM}),8,1)))),
//(tonumber((mid(totext({ART_Consumed_by_reason.IDDLM}),9,2))))
//)

where {..IDDLM} is the date in number format


Q: how does this formula have to look for 200,408.19

thx
 
That was just an example. Replace this line:

numbervar dt := 200408.19;

... with this:

numbervar dt := {ART_Consumed_by_reason.IDDLM};

-dave
 
Dave,

my bad.... (its so easy just to copy/paste!!)

now, how do I get it to be a date field as opposed to a string??

thx again for your help

 
You can remove the Totext function from the second line of Dave's formula:

Date(Int(dt/100), Int(dt) mod 100, (dt * 100) mod 100);


~Brian
 
The only reason I had the ToText in there was because your initial requirement was to display the date in MMDDYY form. I was trying to save you the added step of customizing the display of the resulting Date field.

-dave
 
Dave & Brian

works like a charm....

appreciate your guys' help

thx
 
Here's an easier formula you might want to consider:

NumberToDate({YourField}*100)

Then just format the date the way you want it to look.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
askdon@srhconsulting.com
 
dgillz,

NumberToDate is not an acceptable function/opaeration in the version I use.... CR 8.5 It gives me the following error: 'The remaining text does not appear part of the formula'

thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top