SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help in getting the equivalent month of week

    Hi..

    I have 2 tables for week and calendar days.

    first I have so_week
    fields:
    from_week
    to_week

    second is calendar_days
    fields:
    month_name
    working_days

    sample data:
    from_week : 33
    to_week: 36

    month_name:
    Jan
    Feb
    Mar
    Apr
    May
    and so on

    working_days:
    23
    22
    25
    25
    23

    now I need to get the working days based on from_week to week

    for example from 33 to 36 the month is aug, sep, sep, sep i need to get the working days for that month.

    any help is highly appreciated..

    Thank you so much

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,334
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    it cannot be done with that data
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why??

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,334
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    because

    please explain how you would arrive at the right answer for weeks 33 to 36
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    Non-Member
    Join Date
    Feb 2012
    Posts
    892
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    for example from 33 to 36 the month is aug, sep, sep, sep i need to get the working days for that month.
    If we're talking about two random weeks, then it's very simple. You only need to account for possible start of the year and end of the year incomplete weeks.
    Otherwise, any week in between is a full week: 7 days total minus the 2 days week-end.

    33: 5 days
    34: 5 days
    35: 5 days
    36: 5 days

    20 days total. Of course, you need to count down the legal holidays.

    Unless you mean something else. Like between two random dates.

  6. #6
    SitePoint Addict kduv's Avatar
    Join Date
    May 2012
    Location
    Atlanta, GA
    Posts
    244
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    You would probably want to make a table of all the weeks in a year, and how many working days are in each week number.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •