×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Week Number of a Month in CR 8.5?

Week Number of a Month in CR 8.5?

Week Number of a Month in CR 8.5?

(OP)
Is there a Date function or or do I have to write a formula to determine the week number of a given month (see output example below)
 

Week                     Total Premium
Period                     Amount
Sept 2003 Week 1     $45.00            (ex. this input date would be between 09/01/2003 to 09/06/2003)
Sept 2003 Week 2     $25.00            (ex. this input date would be between 09/07/2003 to 09/13/2003)
Sept 2003 Week 3     $20.00
Sept 2003 Week 4     $30.00
Sept 2003 Week 5     $ 0.00
Oct   2003 Week 1     $10.00

RE: Week Number of a Month in CR 8.5?

Try this:

Insert a group on the date field.  Make sure that you group it for each month.  Also, Suppress the header and footer.  This is needed to keep the next group in the proper order.

Create this formula:

WhileReadingRecords;
dateVar myDate := {Orders.Order Date}; //replace with your date field
numberVar DayNum := Day(myDate);
numberVar Week1Saturday := (7 - DayofWeek(Date(Year(myDate), Month(myDate), 1))) + 1;
stringVar WeekNum;

if DayNum IN [1 to Week1Saturday] then
    WeekNum := "1"
else if DayNum IN [(Week1Saturday + 1) to (Week1Saturday + 7)] then
    WeekNum := "2"
else if DayNum IN [(Week1Saturday + 8) to (Week1Saturday + 14)] then
    WeekNum := "3"
else if DayNum IN [(Week1Saturday + 15) to (Week1Saturday + 21)] then
    WeekNum := "4"
else if DayNum IN [(Week1Saturday + 22) to (Week1Saturday + 28)] then
    WeekNum := "5"
else
    WeekNum := "6";


MonthName (Month(myDate), True) + " " + ToText(Year(myDate),"0000") + " Week " + WeekNum


Group on this new formula.
Add your Summaries to Group Header 2.
Suppress the detail section.

~Brian

RE: Week Number of a Month in CR 8.5?

Or, another approach might be:

Datepart("ww",{table.date})+1
- Datepart("ww",{table.date} - Day({table.date})+1)

I'm not clear what your requirements are, but for the week of September 28, 2003 to October 4, 2003, if {table.date} was September 30, it would return "5", but if {table.date} was October 2, 2003, it would return "1".

-LB

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close