Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert dates to weekdays, then group days and select lowest number

Status
Not open for further replies.

jpalbert

Technical User
Dec 22, 2004
2
GB
Im creating a report from a table with available hotel rooms, the output should be given in pre-decided hotel breaks.
I'm using CR 10, trying to create a crosstab from the table with dates and group them into weekdays. Next, I need to group Monday with Tuesday, Tuesday with Wednesday, Wednesday with Thursday etc. Third, the report need to select the LOWEST number and select it for the column:

Mon/Tue Tue/Wed Wed/Thur..

Hotel1 33 44 24
Hotel2 12 0 11
Hotel3 39 134 21

I used this formula to convert and group dates into weekdays:

Global d1 As Number, d2 As Number, d3 As Number, z As DateTime, x as Number
d1 = {Month.Year}
d2 = {Month.Month}
d3 = {HotelAvailability.Day}
z = Dateserial (d1, d2, d3)
x = Weekday (z, crMonday)
formula = Weekdayname (x)

Please, could anyone give me a hint on how to handle the rest?
 
If you really mean to count each day twice, once in each of two groups, then I think you will have to create a manual crosstab where you group on hotel, and then create formulas like:

//{@Mon/Tues}:
if dayofweek({table.date}) in [2,3] then {table.number}

//{@Tues/Weds}:
if dayofweek({table.date}) in [3,4] then {table.number}

Etc. Then right click on each formula and insert a summary->minimum and suppress the detail section.

-LB
 
Thanks for the help!
Think this is what I'm looking for
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top