Change the definition of a 'Week'?

2019-08-12 07:20发布

问题:

I'm generating an overtime report, and while Crystal Reports can group an employee's shifts into weeks, it uses a standard Sunday-Saturday week; I need a Monday-Sunday week(ie, Sept 12-18th inclusive). Is there any way to change this setting, or am I stuck with writing a complex formula?

回答1:

I don't know of a setting that will allow you to do this, but the group formula is not too bad. The following will give you the week number/index in the year using Mondays as the start of the week.

datepart("ww",{table.date},crMonday)

You will probably want to incorporate the year, too. You can ensure proper sorting by year and week with this

totext(datepart("yyyy",{Orders.Order Date}),"####") + " " 
+ totext(datepart("ww",{Orders.Order Date},crMonday),"##")


回答2:

You could group by {table.date} - 1.