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

I help with a formula to use with a date 1

Status
Not open for further replies.

sniggih

Technical User
Jan 23, 2002
22
0
0
US
I need to formula to return 3 months prior.

I am creating a report that will use a default date range if the user does not select a preferred date range. The default date range needs to be a 12-month range where the ending date is 3 months prior to the latest date in my date filed (Incurred_period). In other words I need my ending date range formula that will give me Maximum(incurred_period) – 3 months. The beginning date range will be 12 months prior to the end date. For example if my last date in the database was March 02 then I need to subtract three months to get the end date (Dec 01). My beginning date range would be 12 months prior to my ending date, which in this example would be Jan 01.
 
No problem:

Formula #1: MaximumDate
Maximum({table.incurred_period})

Formula #2: PeriodEnd
DateAdd(m,-3,{@MaximumDate})

Formula #3: PeriodStart
DateAdd(m,-15,{@MaximumDate})

The first argument in the DateAdd function indicates the type of period. In this case months. The second argument indicates the number of periods and the third indicates the starting date.

cheers. Howard Hammerman,

Crystal Reports training, consulting, books, training material, software, and support. Scheduled training in 8 cities.
howard@hammerman.com
800-783-2269
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top