April 23, 200421 yr Newbies Hi there everyone, Is there perhaps someone who can tell me if there is a way in FM to reverse the date to weeknumber feature? What we want to do here, is fill in a certain weeknumber of the year x, and then we want FM to return the startingdate and the endingdate of that week. Is this possible in a way?? (**When the weekofyear function is used, FM is handling the dates to weeknumber just fine, so now the other way arround?? . . .) Thanking you'll for your reactions, Bruno FileMaker Version: 5 Platform: Windows 2000
April 23, 200421 yr Sure, its possible, but you would need to determine what the exact formula is. Roughly, its going to going to have a structure like: <date for 1/1/<year>> + (weekNum * 7) But you'll need to play around with it to get the exact opposite of weekofyear().
April 23, 200421 yr Author Newbies Thnks Shadow for your reply, but we're still a bit confused about what you mean with <date for 1/1<year>> +(weekNum *7)?? Of course we tried several things to turn arround the function, but nothing seems to work. The strange thing (and there we also think you are right) is that FM is capable of sorting out which date is in which weeknumber. So . . . It has to be possible to display the range (or the first and last) of dates in that weeknumber. Anyone else sugestions?? Bruno
April 23, 200421 yr May be this thread may help. Sunday of WeekOfYear You may adapt the calc so that it runs from Sunday to Sunday+6 FileMaker Version: 6 Platform: Mac OS 9
July 5, 200619 yr Hi, I am using FM Pro 8 and need to reverse the weekofyear function. I was so excited to find this thread, but when I tried going to the link above from ugo and it is not available. Can you please help? Thanks!! Dales
July 5, 200619 yr FileMaker has no problem with determining the WeekOfYear from the date because it has the date to work with. But when given a number WeekOfYear, FiieMaker has no way of determining what week of what year is being requested and the results would vary according to leap years. If you have the associated date then you can reverse it ... but ... that's exactly the problem in why you want it ... you don't know the date. But do you know the year? Or can you determine the year from a modification date or some other method? LaRetta
July 6, 200619 yr These two custom functions can get a date from that week using binary search: DateForWeekNum( yr; weekNum ) = If (weekNum >= 1 and weekNum <= 53; DateForWeekSearch( weekNum; Date(1;1;yr); Date(12;31;yr) ); " DateForWeekSearch( weekNum; startDate; endDate ) = Let( [midDate = GetAsDate( (startDate + endDate) / 2 ); midWeekNum = WeekOfYear(midDate) ]; case (weekNum < midWeekNum; DateForWeekSearch(weekNum; startDate; midDate ); weekNum > midWeekNum; DateForWeekSearch(weekNum; midDate; endDate ); midDate ) ) If you want the date returned to be the sunday starting the week, you can adjust the DateForWeekNum() function to do that easily enough. Hope this helps,
July 6, 200619 yr If (weekNum >= 1 and weekNum <= 53; The WeekOfYear() function returns values 1 through 54.
Create an account or sign in to comment