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

Date Units

Status
Not open for further replies.

EscapeUK

Programmer
Jul 7, 2000
438
GB
I would like the user to select a date range which I can do. I would also like them to select a date unit . for example day, week, month,)

The day para in the report is fine. However how do I group the report on a weekly basis (what if they select a date halfway through the week.

Also how do I display the report on based on the para chosen


ta
 
Crystal has a date range function for grouping. However, you can't control this form a Crystal parameter field.

You could create a formula that takes a column of dates and returns the Day, month or year to use for grouping. Week is tricky since you have to define what you mean by week.

One example is:
{Date} - DayofWeek({Date})

This always returns The Saturday before the date value, so it would group records into Calendar weeks. Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
For week:
You can create a formula field "datetonum" "tonumber(datefield)", and then create three field month1, day1, year1.
if format is mmddyyyy, then:
month1 = left(datetonum,2)
day1 = mid (datetonum,3,2)
year1 = left (datetonum,4)

have the report select by week if it is between

date (year1,month1,day-7) & date (year1,month1,day+7)

Good luck
 
Can this be expanded for the time part of a date time field
 
i fixed it myself

I used hour({datetimefiled})
 
EscapeUK: What version of Crystal are you using? In v8 there are functions to give you the ability to work in weeks and to determine when the week starts etc. David C. Monks
david.monks@chase-international.com
Accredited Seagate Enterprise Partner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top