Jump 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.

Revers the weekofyear function?

Featured Replies

  • 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

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().

  • 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

  • Author
  • Newbies

Thanks Ugo,

It works like charm !!!

greetings Bruno

  • 2 years later...

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

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

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,

Ugo's formula is here.

If (weekNum >= 1 and weekNum <= 53;

The WeekOfYear() function returns values 1 through 54.

Create an account or sign in to comment

Important Information

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

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.