September 24, 201411 yr I am complete Filemaker beginner (self practice), i am working on something that i am struggling with big time 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 ((( immensely will appreciate your attention. Edited September 24, 201411 yr by Lee Smith Font color and style
September 24, 201411 yr 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.
September 24, 201411 yr 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!!!
September 24, 201411 yr 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?
September 24, 201411 yr Hi Smalapi, and welcome to the FM Forums. I changed the Font in your post for you.
September 25, 201411 yr 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!!!
September 25, 201411 yr 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.
September 25, 201411 yr 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.......
September 25, 201411 yr 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.
September 26, 201411 yr 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.
October 1, 201411 yr 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........
October 1, 201411 yr 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.
October 1, 201411 yr 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 = ?
October 1, 201411 yr 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.
October 1, 201411 yr 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!
October 1, 201411 yr 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.
October 1, 201411 yr 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. :-)
October 2, 201411 yr 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