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

Week funktion..

Status
Not open for further replies.

gazol

Technical User
Jan 29, 2004
31
SE
I have formula i use for selecting what type of grouping on time to user it´s like:

if {?time_grouping} = "Hour" Then
cstr({TABLE.TIME},"yyyy-MM-dd HH:00")
else if {?time_grouping} = "Day" then
cstr({TABLE.TIME},"yyyy-MM-dd")
else if {?time_grouping} = "Week" then
totext(datepart("ww",{TABLE.TIME},crMonday),"00")
else
cstr({TABLE.TIME},"yyyy-MM")

The trouble with the formula is that last year hade 52 weeks ? because now when i select to see the week 14 it prints week 15. if i select the dates for week 20 it prints out week 21.

else if {?time_grouping} = "Week" then
totext(datepart("ww",{TABLE.TIME},crMonday),"00")

Is there something i can do to make this work ? Is there any patch ? Other formula that corrects this ?

I'm using crystal reports 8.5.3.936 and i can't use any newer crystal reports version than 8.5 beacause the tool that pulls the reports dosent support newer versions.

I hope someone can give me a solution, i cant get it to work :(

Thanks / GaZoL
 
Last year had 53 weeks not 52, is that whats causing this or is it something else that gives me the wrong week number when the reports is printed ?
 
You need to reference the First Week of Year constant in your datepart formula. The following is from the help section:

crUseSystem 0 Use the NLS API setting.

crFirstJan1 1 Start with week in which January 1 occurs (default).

crFirstFourDays 2 Start with the first week that has at least four days in the new year.

crFirstFullWeek 3 Start with first full week of the year.

The first week of year argument follows the first day of week argument.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top