April 30, 200421 yr Hi I need a calc to give me the week number preceeded by the last 2 digits of the year ( 2004 =04 or 2010 =10 but the catch is that I need the week to be from each Wednesday through Tuesday and change dynamically. The field for this is called Weeknum Not sure how to do this? Any and all your thoughts and expertise very appreciated Dave
April 30, 200421 yr Try something like: Right(NumToText(Year(status(currentdate))),2) &"_" & if(DayOfWeek(status(CurrentDate)) < 4, WeekofYear(status(currentDate)) - 1, WeekOfYear(status(CurrentDate))) You may be able to simplify this a bit. This is for FM6 and earlier. For FM7 change the status functions to the equivalent Get functions.
April 30, 200421 yr Hi Dave, if i understand correctly, for 2004 Jan 1-6 is week 1, Jan 7-13 is week 2, Jan 14-20 is week 3, ... If that's correct, do this: firstWed = Date( 1 , 1 , YEAR ) - DayofWeek( Date( 1 , 1 , YEAR ) ) + 4 + ( 7 * ( DayofWeek( Date( 1 , 1 , YEAR ) ) > 4 ) ) WeekID = Truncate( ( ( Date( MONTH , DAY , YEAR ) - firstWednesday ) / 7 ) + 1 , 0 ) + 1 If you want the days before the first Wednesday to be identified as Week 0, just remove "+ 1" from the end of the WeekID calculation. And so, Weeknum = Right( YEAR , 2 ) & WeekID Jerry
April 30, 200421 yr I just realized that I did not include a NumToText conversion for the IF function. You should enclose the entire IF function in a NumToText conversion. Echo
Create an account or sign in to comment