Newbies brunoo Posted April 23, 2004 Newbies Posted April 23, 2004 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
The Shadow Posted April 23, 2004 Posted April 23, 2004 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().
Newbies brunoo Posted April 23, 2004 Author Newbies Posted April 23, 2004 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
Ugo DI LUCA Posted April 23, 2004 Posted April 23, 2004 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
Newbies brunoo Posted April 23, 2004 Author Newbies Posted April 23, 2004 Thanks Ugo, It works like charm greetings Bruno
Dales Posted July 5, 2006 Posted July 5, 2006 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
LaRetta Posted July 5, 2006 Posted July 5, 2006 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
The Shadow Posted July 6, 2006 Posted July 6, 2006 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,
comment Posted July 6, 2006 Posted July 6, 2006 If (weekNum >= 1 and weekNum <= 53; The WeekOfYear() function returns values 1 through 54.
Recommended Posts
This topic is 6969 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