Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Counting number of days for each season

Featured Replies

I am complete Filemaker beginner (self practice), i am working on something that i am struggling with big time :sad:
 
I need to sort two seasons(High and Low) number of days depending on a given duration between two dates(start & end date). Each season has the following months, Low Season(Dec, Jan, Feb, Mar, May, June, July) the other months are for High Season.
 
I want the following order such that if i enter a start date of 27/07/2015 and End date of 08/08/2015, i must be able to get for Low season 5 days and for High Season 8 days.
 
Do you have any idea, sample script steps, calculation anything to go about on this problem, please help, i am a complete struggle, i can not even start :sad:((( immensely will appreciate your attention.

Edited by Lee Smith
Font color and style

Assuming a duration will never span more than two seasons, try:

 

HighSeasonDays (result is Number)  =

Let ( [
highSeasonStart = Date ( 8 ; 1 ; Year ( StartDate ) + ( Month ( StartDate ) = 12 ) ) ;
highSeasonEnd = Date ( 11 ; 30 ; Year ( highSeasonStart ) )
] ;
Max ( Min ( EndDate ; highSeasonEnd ) - Max ( StartDate ; highSeasonStart ) + 1 ; 0 )
)

---

P.S. Please don't make your posts "pretty". The default font is already difficult enough to read, thank you.

  • Author

Oh Ohh pardon my font - thank you for your response.......

actually the case of the matter is that, the solution should satisfy possibility that duration may span two seasons, so as i have described in the second last paragraph - Also for each season, already the specific months are there, e.g High Season(April, August, September, October & November) and Low Season(December, January, February, March, May, June & July)..........Really feel like i am on wrong career platform and filemaker is abusing me :( please help!!!

the solution should satisfy possibility that duration may span two seasons

 

I said "more than two seasons".

 

 

Also for each season, already the specific months are there, e.g High Season(April, August, September, October & November) and Low Season(December, January, February, March, May, June & July)..........

 

Have you tried the calculation I posted?

Hi Smalapi, and welcome to the FM Forums.

 

I changed the Font in your post for you.

  • Author

Hi Smalapi, and welcome to the FM Forums.

 

I changed the Font in your post for you.

Thank you Lee - Do you think a possible solution exist for my problem? Help.....

 

I said "more than two seasons".

 

 

 

Have you tried the calculation I posted?

i tried without luck - I can not get around the code, at the moment i only have this fields: StartDate, EndDate, HighSeasonDays, LowSeasonDays....i do not know if i have to define extra 4 fields (HighSeasonStart&HighSeasonEnd and same 2 fields for low season) and the reason behind this fields - sorry i am a terrible learner especially with programming........I try!!!

i tried without luck

 

Luck has nothing to do with this. Define the HighSeasonDays field as a calculation field and paste the formula given above into the Specify Calculation window.

  • Author

ohhhh'k, i seem to be getting something for it, but you see the April month belongs to high season but it lies between low season months, so when a duration is spanning March and April for example, all this days are being calculated for Low Season.......

you see the April month belongs to high season

 

Ah. Sorry, I didn't see that. Try this, then:

Let ( [
y = Year ( StartDate ) + ( Month ( StartDate ) = 12 ) ;
aprilStart = Date ( 4 ; 1 ; y ) ;
aprilEnd = Date ( 4 ; 30 ; y ) ;fallStart = Date ( 8 ; 1 ; y ) ;
fallEnd = Date ( 11 ; 30 ; y ) ;daysInApril = Max ( Min ( EndDate ; aprilEnd ) - Max ( StartDate ; aprilStart ) + 1 ; 0 ) ;
daysInFall = Max ( Min ( EndDate ; fallEnd ) - Max ( StartDate ; fallStart ) + 1 ; 0 )
] ;
daysInApril + daysInFall
)

This will work fine for a duration that begins in say December and lasts until the following December (counting both high season periods), but not for a duration that begins in November (or earlier) and lasts until the following April.

  • Author

Ah. Sorry, I didn't see that. Try this, then:

Let ( [
y = Year ( StartDate ) + ( Month ( StartDate ) = 12 ) ;
aprilStart = Date ( 4 ; 1 ; y ) ;
aprilEnd = Date ( 4 ; 30 ; y ) ;fallStart = Date ( 8 ; 1 ; y ) ;
fallEnd = Date ( 11 ; 30 ; y ) ;daysInApril = Max ( Min ( EndDate ; aprilEnd ) - Max ( StartDate ; aprilStart ) + 1 ; 0 ) ;
daysInFall = Max ( Min ( EndDate ; fallEnd ) - Max ( StartDate ; fallStart ) + 1 ; 0 )
] ;
daysInApril + daysInFall
)

This will work fine for a duration that begins in say December and lasts until the following December (counting both high season periods), but not for a duration that begins in November (or earlier) and lasts until the following April.

Yeeaah, i sure did - thank you so much.

  • Author

Hi Comment, this me again :)

 

Thank you for your solution, i took time to define all the variables in the table and after doing some reading on the LET() function i realised i needed to clean up that mess, so now.......please i need help to decipher some part of that solution, i do not understand what the value of y is going to be for this variable declared as:

 

 

y=Year(StartDate) + (Month(StartDate) = 12);

 

Could you please break it down a little in explaining what is going on here, i tried i could not get it........

y = Year ( StartDate ) + ( Month ( StartDate ) = 12 ) ;

 is a short way to write:

y = Year ( StartDate ) + If ( Month ( StartDate ) = 12 ; 1 ) ;

By default, the formula calculates the dates of the two high-season periods in the year of StartDate. However, when StartDate is in December, both high-season periods have already elapsed, so the calculation moves to the following year.

  • Author

Sorry am so lost - can we use an example two dates, start: 28/11/2014 End: 15/01/2015, in this case what is the year or value for the variable y = ?

What is the numerical value of month 11? Is 11 = 12 or not?

Sorry am so lost - can we use an example two dates, start: 28/11/2014 End: 15/01/2015, in this case what is the year or value for the variable y = ?

 

You should be able to find this out for yourself - for example, by using the Data Viewer.

  • Author

Given the start date 28/11/2014, the numerical value of month is 11 and my confusion does not clear here, assigning 11 a value of 12 then adding that to 2014 or what is going on really............feeling dumb big time!

assigning 11 a value of 12

 

In Filemaker, = does not assign a value*; it compares and returns a True or False (1 or 0) result.

 

---

(*) except within the Let() function, when used in the appropriate place.

Put this portion of Comment's calc in your data viewer: 

 If ( Month ( StartDate ) = 12 ; 1 )

You will get a 1 or empty.  This means that "if the month of the start date equals 12 (is December) then return '1' ... which adds a 1 to the year of the start date if the month is 12.  

 

And don't feel bad about your confusion, Miss A ... you are willing to ask the questions so you understand instead of using a calculation which makes no sense and then just moving on.  :-)

  • Author

Thank you LaRetta for coming through to me - i seem to be getting somewhere slowly but surely, with a bit more practice.........thanx :)

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.