Jump to content
Sign in to follow this  
Mike J

Date/Calendar Calc

Recommended Posts

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

)



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

) 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

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