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

Truncate Isn't Working

Status
Not open for further replies.

FireGeek21

Technical User
Dec 12, 2007
218
US
I am adopting a formula from Ken Hamady (thank you Ken) that looks at the number of work days between two dates. My adoption is just getting the week number between two dates as follows:

WhileReadingRecords;
Local DateVar Start := Date(2009, 01, 01);
Local DateVar End := CurrentDate;
Local NumberVar Weeks;

Weeks:= (Truncate ( (End - DayOfWeek(End) + 1) - (Start - DayOfWeek(Start) + 1) ) /7 );

This is returning 84.00 and I want only 84. This is for a fixed field file so using the field formating is not an option.

Why isn't Truncate working? Round works but I really don't want it to actually Round, just want it to drop the zero's after the decimal.

Thanks!



FireGeek
(currently using Crystal Reports XI with Lawson 8.03)
 
You could convert it to a text field, by making weeks a string variable:

weeks := totext(Truncate ((End - DayOfWeek(End) + 1) - (Start - DayOfWeek(Start) + 1))/7,"00");

---assuming you want two digits for weeks.

-LB
 
Thank you for the response LB. Here is what I ended up doing...

WhileReadingRecords;
Local DateVar Start := Date(2010, 01, 01);
Local DateVar End := CurrentDate;
Local NumberVar Weeks;

Weeks := Truncate((End - DayOfWeek(End) + 1 - (Start - DayOfWeek(Start) + 1)) / 7);
ToText(Weeks, "00000");


I do need 5 positions for this field with preceeding zeros. I thought it was odd Truncate did not seem to be working.

Seems we ended up doing the same thing to get the same end result.

Thanks!!!

FireGeek
(currently using Crystal Reports XI with Lawson 8.03)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top