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!

formula for determining current school year? 1

Status
Not open for further replies.

obuspider

Programmer
Oct 31, 2002
78
0
0
US
I'm trying to create a formuala that would determine the current school year which runs from August to May. Right now, I have it set up as a formula to determine the fall, and another to determine the spring, however, it isn't working. Any ideas?

This is what I have right now

If {@monthcurrentdate} = "8" or
{@monthcurrentdate} = "9" or
{@monthcurrentdate} = "10" or
{@monthcurrentdate} = "11" or
{@monthcurrentdate} = "12" then

year(CurrentDate + 1)

Else

year(CurrentDate)
 
The following formula will evaluate if a certain date field(change the {your date field} to the your date field that is to be evaluated) It will display "current year" if the date is between Aug 1, 2002 and May 5, 2003 and "not in current year if the date falls outside of the range

if{your date field} in date(2002,8,1) to date(2003,5,30)
then "current year" else "not in current year"


Extra info;
year(CurrentDate + 1)= the year of tomorrow -( 2003 )
year (CurrentDate)+ 1 = next year ( 2004 )


Mike
If you're not part of the solution, you're part of the precipitate.
 
mbarron,

thanks for the info. This is assuming that I have a specific date range. What if I want the date where you have 2002,8,1 to be dynamic and change with each year.

I need to determine if the current month is in the fall. If it is, then the year for the fall sem is the current year otherwise, it is the current year - 1.

Does this make sense?
 
Is your current month to which you are refering today's month, or for a date in a table?



Mike
If you're not part of the solution, you're part of the precipitate.
 
Here is a formula that will check a date in a table to see if it is in the fall (aug through dec) or the spring (jan through may). If it is in the fall, it will display the year the date occurs + 1. If the date is in the spring, it will display the year.

datevar checkme;numbervar schlyear;numbervar term;
checkme:={@date};

if month(checkme) in 8 to 12 then schlyear:=1 else
if month(checkme) in 1 to 5 then schlyear:=0;

term:=year(checkme)+schlyear


Mike
If you're not part of the solution, you're part of the precipitate.
 
This sounds just like a fiscal year calculation, and if so it can be done simply with:

Year ( {Field.Date} + 153 )

The number 153 is the number of days between August 1 and January 1 of the next year. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Ken's formula is the simplest and it works. Just for your understanding, your origional formula was not working because you are extracting the year based on the current date + 1 day. The plus one should be outside of the parenthesis.

year(CurrentDate) + 1

Good luck.
 
Thanks for all your help. I knew there had to be any easier way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top