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!

End of month Date function in Crystal 8.5?

Status
Not open for further replies.

MyNeckHurts

Programmer
Apr 5, 2002
34
US
Does anyone know how to get the last day of a month in Crystal 8.5? I have a date field and I need to get a percentage using the amount of days in a given month. Thanks!

 
I found the answer. Here it is:

// Find the first date of the month based on the date field
datetimevar firstDate:= datetime(year({DC_STOCK_OUT_LOW.cal_date}), month({DC_STOCK_OUT_LOW.cal_date}),1,0,0,0) ;


// Find the first date of the next month based on the date field
datetimevar nextMonth:= dateadd("m",+1,firstDate);


// Subtract one day from the first date of the next month. This gives you
// the last day of the month based on the date field.
nextMonth:=dateadd("d",-1, nextMonth);
//day(nextmonth)

// Finds the Percentage of stock out by dividing the total stock outs by the days in the month
{DC_STOCK_OUT_LOW.STOCK_OUT_DAY}/day(nextMonth)
 
Try:

dateadd("m",1,datetime(year({DC_STOCK_OUT_LOW.cal_date}), month({DC_STOCK_OUT_LOW.cal_date}),1,0,0,0))-1

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top