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

Returning month name from date range parameter 1

Status
Not open for further replies.
Feb 17, 2004
52
GB
CR 8.5
SQL tables

Is this possible?

I have the following parameter in my record selection formula:

{IncidentHeader.ArriveDT} = {?Date Range}

The date range is normally 1 month (eg. 01/02/2004 to 29/02/2004)

What I want is to be able to pull out the words "February 2004" from my date range parameter so that I can print them in headers and footers on my report.

At the moment I have a separate parameter set up so I have to type in "February 2004" and then it populates my report.

Is there a way of automating this? Perhaps I can specify a month in the first instance rather than a date range each time? Any suggestions?

Thanks


Lido
Development & Reporting
UK
 
If you want the Month/Year of the lower date range value, you can create a formula and drop it into your report header:

monthname(month(minimum({?DateRange}))) + " " + totext(year(minimum({?DateRange})),0,"")

-dave
 
Something like this should work:

@StartDt
Monthname( Month ( Minimum ( {?Date Range} ) ) )

@EndDt
Monthname( Month ( Maximum ( {?Date Range} ) ) )

@StYear
Year( Minimum ({?Date Range} ))

@EndYear
Year( Maximum ({?Date Range} ))

(I setup the years separately so can easily format it with no decimals...)

Then setup you text field as
'From @StartDt @StYear To @EndDt @EndYear'

Admittedly I usually just put the text part in and drag the formulas into place --lazy sot that I am.

Scotto the Unwise [sunshine]
 
As you state the range is "normally 1 month", suggesting it might encompass a larger period, I would be careful about relying purely on the minimum or maximum aspect of the range.

A formula stating the following should cut it:
Code:
If Month(Minimum({?DateRange})) = Month(Maximum({?DateRange}))
Then MonthName(Month(Minimum({?DateRange}))) + " " + ToText(Year(Minimum({?DateRange})),0,"")
Else MonthName(Month(Minimum({?DateRange}))) + " " + ToText(Year(Minimum({?DateRange})),0,"") + " to " +
MonthName(Month(Maximum({?DateRange}))) + " " + ToText(Year(Maximum({?DateRange})),0,"")
Naith
 
Vidru that's the answer I was looking for. Thanks very much!

Scotto I'm sure your answer would have worked too but Vidru's suggestion was what I was hoping for.

Thanks both for your help!



Lido
Development & Reporting
UK
 
Naith

A very good point there! It would definitely worth be changing the formula to what you have suggested to cover any possibilities.

Lido
Development & Reporting
UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top