Miss A! Posted September 24, 2014 Posted September 24, 2014 (edited) 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, 2014 by Lee Smith Font color and style
comment Posted September 24, 2014 Posted September 24, 2014 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. 1
Miss A! Posted September 24, 2014 Author Posted September 24, 2014 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!!!
comment Posted September 24, 2014 Posted September 24, 2014 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? 1
Lee Smith Posted September 24, 2014 Posted September 24, 2014 Hi Smalapi, and welcome to the FM Forums. I changed the Font in your post for you.
Miss A! Posted September 25, 2014 Author Posted September 25, 2014 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!!!
comment Posted September 25, 2014 Posted September 25, 2014 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.
Miss A! Posted September 25, 2014 Author Posted September 25, 2014 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.......
comment Posted September 25, 2014 Posted September 25, 2014 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. 2
Miss A! Posted September 26, 2014 Author Posted September 26, 2014 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.
Miss A! Posted October 1, 2014 Author Posted October 1, 2014 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........
comment Posted October 1, 2014 Posted October 1, 2014 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.
Miss A! Posted October 1, 2014 Author Posted October 1, 2014 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 = ?
bruceR Posted October 1, 2014 Posted October 1, 2014 What is the numerical value of month 11? Is 11 = 12 or not?
comment Posted October 1, 2014 Posted October 1, 2014 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.
Miss A! Posted October 1, 2014 Author Posted October 1, 2014 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!
comment Posted October 1, 2014 Posted October 1, 2014 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.
LaRetta Posted October 1, 2014 Posted October 1, 2014 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. :-)
Miss A! Posted October 2, 2014 Author Posted October 2, 2014 Thank you LaRetta for coming through to me - i seem to be getting somewhere slowly but surely, with a bit more practice.........thanx
Recommended Posts
This topic is 4042 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now