Jump to content

This topic is 7582 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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.

Posted

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

Posted

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

This topic is 7582 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.