Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Unusual report

by shilpam (Sexton)
on Jan 31, 2005 at 09:40 UTC ( #426535=perlquestion: print w/replies, xml ) Need Help??
shilpam has asked for the wisdom of the Perl Monks concerning the following question:

I need help for an unusual kind of report. I need to create a following kind of report. It can be in either csv or html format. Or perhaps if not possible in either of the two, then can you suggest some other format and how to get it. I need the logic - how to go about it, based on the date how do I get the day of the week and display it.
The report is something like -
Input to this report will be a date range.
Pl. note - all the text in bold will be a static text...I mean Room 1, Room 2, Room 3. And the dates should be displayed based on user input and their respective day of the week.
For e.g. the date range is Jan 3, 2005 - Jan 14, 2005. So, the report should look like -
January 2005
  Mon Tue Wed Thur Fri
  3 4 5 6 7
Room 1 Class A Class A Class A    
Room 2   Class B      
Room 3          
  10 11 12 13 14
Room 1          
Room 2          
Room 3 Class C Class C Class C Class C Class C

Replies are listed 'Best First'.
Re: Unusual report
by holli (Monsignor) on Jan 31, 2005 at 09:54 UTC
    If you want to create a report, you are likely to have some input data for that report. It is very hard, if not impossible, to advice you, without knowledge what that data looks like, or where it comes from.

    holli, regexed monk
Re: Unusual report
by edan (Curate) on Jan 31, 2005 at 10:52 UTC
Re: Unusual report
by punch_card_don (Curate) on Jan 31, 2005 at 14:40 UTC
    I believe the real question is carefully concealed in this phrase:

    based on the date how do I get the day of the week and display it.

    That is, when the user asks to start the calendar at January 3, 2005, how do you know what day of th eweek that falls on so as to correctly format your calendar?

    You need the Perl moduleDATE::CALC

    which has the functions:

    #returns the week number of the date input $week = Week_of_Year($year,$month,$day); #returns the date of the monday of the week input ($year,$month,$day) = Monday_of_Week($week,$year);
    So you can do, (pseudo code):
    - get $begin_day, $begin_month, $begin_year and $end_day, $end_month, +$end_year from form input $begin_week = Week_of_Year($begin_year,$begin_month,$begin_day); ($begin_year,$begin_month,$begin_monday) = Monday_of_Week($begin_week, +$begin_year); $end_week = Week_of_Year($end_year,$end_month,$end_day); ($end_year,$end_month,$end_monday) = Monday_of_Week($end_week,$end_yea +r); #note that in above month and year get changed in case the range strad +dles months or years - calculate $number_of_weeks in range either using a Date::Calc functi +on or $end_week - $begin week $monday_date = $begin_monday; for $w (1 .. $number_of_weeks) { print days-of-week row; print dates row starting at $monday_date for $r (1 .. $number_of_rooms) { get room data and print it; } $monday_date = $monday_date +7; }

    Forget that fear of gravity,
    Get a little savagery in your life.

      Update:Do this, don't do that....(Five Man Electrical Band)
        Youīre a Friar, why donīt you do it yourself?

        In the previous node, punch_card_don asked for a jantitor to consider the OPīs question to be retitled.

        punch_card_don, do not delete contents of a node somebody has already replied to, because that leaves the reply "in the void", possibly senseless. You can add new contents (make that clear with an "Update:"-statement, or you may even strike out contents like this.

        holli, regexed monk

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://426535]
Approved by fxmakers
and the monks are mute...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2018-03-23 22:52 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (297 votes). Check out past polls.