This topic is locked

Print a schedule from first date to last date

7/27/2011 4:14:04 PM
PHPRunner General questions
P
pim author

Hi there,
I have created a view called 'f_tour_schedule'. One field in this table is called 'StartDate'
I would like to print this view based on a sorting of 'StartDates', (logically) starting with the first date and ending with the last date. How can I do that?
I have already tried (how-to-calculate-dates-on-the-fly-and-use-that-calculated-value), but I can't get it to work.
Another related question I have is; the table 'f_tour_schedule' has three other fields: 'EndDate', 'NrOfDays' and 'NrOfNights'.

Which code I would have to add so that 'NrOfDays' and 'NrOfNights' automatically get calculated? They are originating from the table 'f_tours'.
Thank you so much for taking the time answering me,
Greetings Pim

C
cgphp 7/27/2011



I would like to print this view based on a sorting of 'StartDates', (logically) starting with the first date and ending with the last date. How can I do that?


If you only need to sort the records by the StartDate field, in the BeforeQuery event of the print page of the view, paste this code:

$strOrderBy = "ORDER BY StartDate DESC";




Another related question I have is; the table 'f_tour_schedule' has three other fields: 'EndDate', 'NrOfDays' and 'NrOfNights'.

Which code I would have to add so that 'NrOfDays' and 'NrOfNights' automatically get calculated? They are originating from the table 'f_tours'.


If the date format doesn't include a time (and you don't use a shift time for day and night):

$value = round((strtotime($data['EndDate']) - strtotime($data['StartDate'])) / 86400); //this code is valid for a custom field