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

Date Calculations

Status
Not open for further replies.

Acydman

IS-IT--Management
Nov 18, 2004
52
GB
I want to calculate two numbers, one is the number of days (excluding weekends) that have passed month to date and the other is the number of days remaining in the month (again excluding weekends)

I am writing this in Crystal Reports 9

Thanks

Mark
 
You should be able to adapt Ken Hamady's formula for work days for this:


You would use:

currentdate-day(currentdate)+1

...for Start and Currentdate for End in one formula, and for the second, use currentdate for Start and use:

dateadd("m",1,currentdate-day(currentdate))

for End in the other formula.

-LB
 
Hi Mark,

You could try the following two formulas:

1.) @DaysSoFar
Code:
Global DateVar tdy := CurrentDate ;
Local Datevar first := Date(Year(tdy), Month(tdy),1) ;
Local NumberVar since ;

since := ( DateDiff('d',first,tdy) 
            - DateDiff('ww',first,tdy,crsaturday) 
            - DateDiff('ww',first,tdy,crSunDay) ) +1;


2.) @DaysToGo
Code:
Global DateVar tdy ;
Local Datevar last := DateSerial(Year(tdy), Month(tdy)+1,1-1) ;
Local NumberVar togo ;

togo := ( DateDiff('d',tdy,last) 
            - DateDiff('ww',tdy,last,crsaturday) 
            - DateDiff('ww',tdy,last,crSunDay) ) ;




Bob Suruncle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top