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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting weekdays

Status
Not open for further replies.

msay

Programmer
Aug 17, 2001
56
US
Maybe this is simple, but I just can't get it. I am using Report designer in VB. I have a group called salesman (sorted by salesman), and a field called DayofWeek. I want to sort the days of the week so Monday is first. Any Help? Thanks.
Mike Sayler
 
I'm presuming you have a formula that returns the name of the day? If you do, change your formula so that it returns;

"1. Monday" instead of "Monday"
"2. Tuesday" instead of "Tuesday".. and so on.

etc. Crystal sorts on the first character, so you can force it to sort how you need it to by adding in a character or characters of your choice.

Peter Shirley
 
If you are using the dayofweek function, do the following:

dayofweek({table.date},2)

This makes Monday the first day of the week, and the formula will return a 1 for Monday, 2 for Tuesday, etc.

You can group on this to get the correct order, but then delete the group name from the group header and use the following for display:

weekdayname(dayofweek({table.date},2),false,2) //where the false indicates no abbreviation of the weekdayname, and the 2 again designates the beginning day of the week, in this case Monday.

-LB
 
I should have been more descriptive. The database field "DayOfWeek" is in the Details section. So what happens is that a particular salesman will have x amount of leads per week day. The report, when run lists in the detail section the salesmans name, dayofweek and num of leads. The dayofweek seems to come up in no particular order. ex. Friday, Monday, Thursday ... What I would like to have happen is Monday first and so on. Thanks.
MS
 
Create my formula for dayofweek and then go to report->sort records and insert the formula to achieve the order you want. Or you can group on the dayofweek formula and suppress the group header and footer.

-LB
 
The days are coming up in ALPHABETICAL order, because they are words not dates. If you have a true date field, sort on that. If not write a formula like the following:

if {field} = "Monday" then 1 else
if {field} = "Tuesday" then 2 else
if {field} = "Wednesday" then 3 else ....


And then sort on this formula. You don't have to see this formula to sort on it.


Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
Ken, I took your suggestion. It worked great. Thanks to all!!
MS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top