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

Script for creating dates per WeekofYear

Featured Replies

Is there a script that can create a record for each date in the Week of Year.

In orther words, today's date falls within the 14th week of the this year. I would like to be able to put a start date, such as 4/1/03, into a field, and then run a script that would create a record for each date 4-1-03 to 4-15-03 (inclusive), for each employee.

Does this make sense? Is there a better way to approach this?

TIA

Lee tongue.gif

The date range you gave in your example is 2 weeks, and starts on Tuesday, so I'm not sure if that was a typo or intentional. But here is a sample script that will generate dates from Sunday to the following Saturday for the current date:


Set Field [gStartDate, Status(CurrentDate)-DayOfWeek(Status(CurrentDate))]

Set Field [gCounter,1]

Loop

  Exit Loop If [gCounter>7]

  New Record/Request

  Set Field [Date, gStartDate+gCounter]

  Set Field [gCounter,gCounter+1]

End Loop

You can adjust the range by changing the 'Exit If' statement, and adjust the starting weekday by adding or subtracting an offset to the Date.

  • Author

Thank you Bob, that works great.

Lee laugh.gif

  • Author

Hi Vaughan,

I've seen it, I've studied it, and two years after downloading it, I still don't understand it.

Thank you for your response though, I really do appreciate it.

Lee

smile.gif

"I've seen it, I've studied it, and two years after downloading it, I still don't understand it."

Yeah, well, I just cut and paste the calculations between the sample file and mine and hope it works!

  • 3 weeks later...

Hi Lee, Hi Vaughan,

Well I've studied it also for the last 4 hours, and pasted all combinations, then modified them to the proper french definitions for my FM . But it still doesn't work. I've got a strange number result, not a Multikey.

I wondered if you've solved this one as it is exactly what I'm looking for.

Enter a Week N

OOps, I feel stupid !

1. I've dowloaded it from fmfiles

2. My pastes were OK as long as my own method. It's just that carriage returns in Num fields....

3. I even tried with the text field and it seems to work fine with both text and num results, don't know why ?

Maybe a litte (non related to FM ) question, to feel again even more stupid. Are there always 53 weeks in a year ?

  • Author

Hi Ugo,

Are you saying the calculations in your post work for a relationship multikey out of the box?

Maybe it's time to play around with it some more?

Lee confused.gif

Yes Lee,

Multi-key =

MIDDLE(VALUELISTITEMS(STATUS(CURRENTFILENAME); "weeklist");

POSITION(VALUELISTITEMS(STATUS(CURRENTFILENAME); "weeklist"); "

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.