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.

Date/Calendar Calc

Featured Replies

Hi All. Hope the New year is treating you well!!!

I would like some advice on how to break this calc down.

This repeating field calc is used to display a calendar. I have buttons over top (result gives 40 days) with a script parameter from 1 to 40. What I want to do is select the date in a return delimited fashion into another field. I can't seem to grasp the math/parameters in this calc. Is there anyway you can break it apart for me?

Thanks

Mike


Let(

[



dateExtended = Extend( Login_Today ); // Change the field references in the Extend function



monthDay1 = Date ( Month( dateExtended ) ; 1 ; Year( dateExtended ) );

day0 = monthDay1 - Mod (monthDay1 ; 7 ) - 1;

theDate = day0 + Get ( CalculationRepetitionNumber );

dNum = TextSize ( Day( theDate ); 9 )



];

//--------------------------------



Case(

theDate = Get ( CurrentDate ); TextColor(TextStyleAdd( dNum;Bold );RGB(255;0;0));

Month( theDate ) = Month( dateExtended ); dNum;

TextColor( dNum; RGB(200;200;200) )

)



//--------------------------------

) 

The problem here is that the calculation returns a number (the day part of a date), not a complete date. This number could be in the current month, or the one before, or the one after. Therefore, in order to select a date, you need to repeat the same calculation with a date result - either in the selecting script itself, or in the script parameter, or in another calculation field.

For example, you could have a script that does:

Set Field [ SelectedDate ; Let (

firstOf = Date ( Month ( Login_Today ) ; 1 ; Year ( Login_Today ) )

;

firstOf - DayOfWeek ( firstOf ) + Get ( ScriptParameter )

) ]

BTW, why 40 and not 42? See:

http://fmforums.com/forum/showpost.php?post/205680/

I am also not sure what "select the date in a return delimited fashion" means.

---

EDIT:

Why don't you simply use the native drop-down calendar?

Edited by Guest

  • Author

Hi Comment,

Thanks for the test script parameter.

The reason for not using the native drop down calendar is two fold.

It gets back to me letting the user select multiple dates to create an event. Unless there is another way of doing this?

It also allows me to have one layout dedicated to this calendar for presentation as a pop up or displayed on the layout so that when you my users want to see the date and upcoming dates it is there.

I'll try what you provided to see if it does what I require.

Thanks again!

Mike

I am not sure putting multiple dates in a single field is a good idea (if I understood you correctly). I would rather have a StartDate field and an EndDate field.

  • Author

I think you are right!!

M

Create an account or sign in to comment

Important Information

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

Account

Navigation

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.