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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Days to Years, Months, Days

Status
Not open for further replies.

WPCMS

Technical User
Jun 28, 2007
29
US
I am trying to take an In Process date and count how many Years, Months, and Days it has been In Process from CurrentDate. Awhile ago someone gave me the formula below but it didn't work. It returns "0 Yrs 0 Mos 17 Days". What am I missing?

//The following assumes you have inserted a group on {table.acct} and that you have
//one date field you are comparing across years.
//Go to the field explorer->formula->new and enter:

datetimevar min := minimum({@Character field to date field in process date});
datetimevar max := maximum({@Character field to date field in process date});
numbervar yrs := datediff("yyyy",min,max);
numbervar mos;
if month(max) >= month(min) then
mos := datediff("m",min,max)-(yrs*12) else
if month(max) < month(min) then (
yrs := yrs-1;
mos := datediff("m",min,max)-(yrs*12)
);
numbervar days :=
if day(max)>= day(min) then
days := day(max) - day(min) else
if day(max) < day(min) then (
mos := mos-1;
days := day(max)+(day(max-day(max))-day(min))
);
totext(yrs,0,"")+" Yrs "+totext(mos,0,"")+" Mos "+totext(days,0,"")+ " Days"
 
Please disclose the contents of {@Character field to date field in process date} as well as any imbedded formulas.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Our system has our dates set up as 2008-01-23.


//A date field can sometimes be a character field. This formula changes to a date
if {CallLog.InProcessDate} startswith "2"
then
(numbervar yr := tonumber ({CallLog.InProcessDate}[1 to 4]);
numbervar mo := tonumber ({CallLog.InProcessDate}[6 to 7]);
numbervar dy := tonumber ({CallLog.InProcessDate}[9 to 10]);
date (yr,mo,dy))
 
Dump the variables:

if {CallLog.InProcessDate} startswith "2" then date(tonumber({CallLog.InProcessDate}[1 to 4],tonumber({CallLog.InProcessDate}[6 to 7]),tonumber {CallLog.InProcessDate}[9 to 10])) else {CallLog.InProcessDate}



Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
The last {CallLog.InProcessDate} says a number is required here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top