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!

extracting the month from a date range 1

Status
Not open for further replies.

Toxodont

IS-IT--Management
Jul 12, 2002
52
CA
Hello I have a parameter called {?the_date} and I use it to specify a month's worth of data. How can I extract the month of the range (into a variable named the_month so I can use it in the bellow switch statement:

Switch
(
the_month = 1, "January",
the_month = 2, "Februrary",
the_month = 3, "March",
the_month = 4, "April",
the_month = 5, "May",
the_month = 6, "June",
the_month = 7, "July",
the_month = 8, "August",
the_month = 9, "September",
the_month = 10, "October",
the_month = 11, "November",
the_month = 12, "December",
True, "null"
) //end switch


Thank you in advance for your help.

penpen.gif

Toxodont
 
In Crystal 8.5, you can get the month-name directly from the date. Try
Totext ({?the_date}, "MMMM")
I'm assuming the parameter is a date, use Cdate to convert it if not. You can also extract the month number as M or MM (MM has leading zeros)

Madawc Williams
East Anglia, Great Britain
 
You might want to use this instead: MonthName({YourDate})
 
I mean MonthName(Month({YourDate})) - or the method Madawc suggests.
 
{?the_date} is a date range though remember. Some of those formulas don't accept a range as a date for some reason...
 
Naturally you can't put the full range in it. If you put a ranged parameter into it, you'd have to use something like MonthName(Month(Minimum({?YourDateRange}))) or Maximum. Or better still, use the database datefield instead of the parameter.

If you still need a more tailored response, you will really need to provide some more information, preferably using an example, about what you are trying to do.

Naith
 
Thank you very much Naith, my date is working perfectly now! I just used that exact code and put in my parameter and voila it worked great! Thanks again for the help!
 
Okay.

Just bear in mind that if you used minimum or maximum on their own, this will only be any good to you if your range is always within the same month. If your range can go over two or more months, you will have to think about representing each month in the range separately.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top