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.

Featured Replies

I found a way to get the week of the month from a date field. I first thought it would be easy but found out that FMP doesn't have a week of month function...

Enjoy...

code:


Case(

(Day(Date) - DayofWeek(Date)) < 1, 1,

(Day(Date) - DayofWeek(Date)) < 8, 2,

(Day(Date) - DayofWeek(Date)) < 15, 3,

(Day(Date) - DayofWeek(Date)) < 22, 4,

(Day(Date) - DayofWeek(Date)) < 31, 5,"")

  • 3 weeks later...

Thanks very much for this. I'm going to be using it very soon.

Regards, Keith Silva

  • 2 years later...

Thanks a lot!!! That really helped me out of a bind. I plan to post my calendar program that I modified from the samples database to all who want to use it. I am still working out a few bugs but the final product will have event repetition by week/month, printable calendar layouts, multi-user capable, and MYSQL web integration.

Regards,

Adrian

Hi Steve,

Thanks for sharing. However, look out for months that have 6 weeks in them like 3312003

smile.gif

Good call Lee....

Let see...

If the First Sunday of the Month for this date falls in the same week than the first day of this given month, then the "WeekofMonth" could be easily calculated using the gap between the WeekofYear(First Sunday of Month) and the WeekofYear for the given date.

If not, we should add 1 week to this calc.

So maybe this would work

WeekofMonth =

(WeekofYear(date)+1)-(WeekofYear(DATE(1,1,Year(date)) - Mod(DayofWeek(DATE(1,1,Year(date))) +6, 7) + (WeekofYear(Date(Month(date),1,Year(date))) * 7))- not WeekofYear(Date(1,1,Year(date)) - Mod(DayofWeek(Date(1,1,Year(date))) +6, 7) + (WeekofYear(Date(Month(date),1,Year(date))) * 7)) = WeekofYear(Date(Month(date),1,Year(date))))

where :(

Oh well....

First the above calc wasn't returning a correct result if the first day of year was a Sunday.

Second, I just love these easy calculations you won't even try at first, sure it won't produce accurate rsults.

In fact,

(WeekofYear(date)+1)-WeekofYear(Date(Month(date),1,Year(date))) is working smirk.gif

Hi Ugo,

Nice job! I couldn't break it.

Now watch someone come along with a choose or mod calc that makes it shorter

Lee

grin.gif

Lee,

I doubt a Case or Mod could make it smaller than it is right now...

(WeekofYear(date)+1)-WeekofYear(Date(Month(date),1,Year(date)))

Maybe something like :(

Choose(WeekofYear(date)-WeekofYear(Date(Month(date),1,Year(date))),1,2,3,4,5,6) grin.gif

And BTW, here's the corrected useless complicated calc ???

(WeekofYear(date)+1)-(WeekofYear(Date(1,1,Year(date)) - Mod(DayOfWeek(Date(1,1,Year(date))) +6, 7) + (WeekofYear(Date(Month(date),1,Year(date))) * 7))-

not (Year(Date(1,1,Year(date)) - Mod(DayofWeek(Date(1,1,Year(date))) +6,7)) =Year(date) and not Day(Date(1,1,Year(date)) - Mod(DayofWeek(Date(1,1,Year(date))) +6, 7))=1)))

tongue.gif

Hi Ugo,

Ugo DI LUCA said:

I doubt a Case or Mod could make it smaller than it is right now...

That was suppose to be a joke

smile.gif

Lee

If it's any consolation, I giggled.

Since we're on weeks calcs, does anybody have 2 calcs that will return the Sunday date and the Saturday date of a week (assuming the week starts on Sunday)? Click on Tues, and display his schedule for Sunday thru Sat of that week.

Steve

Sunday = datefield - DayofWeek( datefield ) + 1

Saturday = datefield - DayofWeek( datefield ) + 7

That was easy. Thanks, Steve

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.