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.

Hoping for help RE: date field calculation

Featured Replies

Hi there, was hoping for a little help, as I am stumped. I am using FM 8.5 and I have a field that I use to show a date, usually, 1 year from the current date. Right now, I have FM auto fill the field with the current date, then change it manually to 1 year beyond. Is there a way to script a button to automatically insert the date + 1 year? Thanks

PS. we use 8.5 client and 9.0 server, any chance for corrupted data in my unique identifier? Thanks

Hi,

You should be able to use Set Date Field = Get(CurrentDate)+365; where 365 = days per year and Get(CurrentDate) returns the current date. Alternately you can have a global field defined as "years or days to add", and add that as part of the automatic calculation, so the button need not be pressed.

If you must also account for leap years, a CASE statement on the year can achieve that.

  • Author

Date field is used to track follow up appointments at a medical office. I want to click on one of 3 buttons to set a follow up date for 1 yr, 6 months or 3 months. I'll try these 2 methods out, thanks so much!

Hi Stevireno,

LaRetta has given you a calculation that would work for the 1 year, you can also use Date Field + 365 to get the One Year from your date.

Attach your scripts to a button and use the Set Field script step to set your future follow up date.

Be sure your Calculation Results as a Date

3 months

Set Field(FutureDate; YourContactDate + 90

6 months

Set Field(FutureDate; YourContactDate + 180

1 year

Set Field(FutureDate; YourContactDate + 365

Set Field [FurtureContacDate; Date ( Month (ContactDate ) [color:blue]+3 ; Day (ContactDate ) ; Year

(ContactDate ) ) ]

Set Field [FurtureContacDate; Date ( Month (ContactDate ) [color:blue]+6 ; Day (ContactDate ) ; Year

(ContactDate ) ) ]

Set Field [FurtureContacDate; Date ( Month (ContactDate ) ; Day (ContactDate ) ; Year

(ContactDate ) [color:blue]+ 1 ) ]

or using LeRatta's calculation

3 months

Date ( Month ( Get ( CurrentDate ) [color:blue]+ 3 ) ; Day ( Get ( CurrentDate ) ) ; Year ( Get ( CurrentDate ) ) )

6 months

Date ( Month ( Get ( CurrentDate ) [color:blue]+ 6 ) ; Day ( Get ( CurrentDate ) ) ; Year ( Get ( CurrentDate ) ) )

1 year

Date ( Month ( Get ( CurrentDate ) ) ; Day ( Get ( CurrentDate ) ) ; Year ( Get ( CurrentDate ) ) [color:blue]+ 1 )

HTH

Lee

Edited by Guest

  • Author

A thing of beauty...

Thanks Lee...

Your welcome,

I made a sample so you can see the different calculations in action.

Stevireno.fp7.zip

Just want to point out that LaRetta's solution is the strongest in the thread.

Get(CurrentDate) + 365 will only return the correct result 75% of the time.

And the +90 and +180 will work less than that.

  • Author

Very good, thanks again guys...

That is a moot point.

Read again what the need is.

First of all, I never said that one calculation is better than the other. In fact, if you had looked at the example file I posted for Stevireno, you would see that I gave examples of both calculations, three scripts, and three calculation fields, just so that Stevireno could see the difference. I don't think it really matters here which one is used.

Date field is used to track follow up appointments at a medical office

Because, every doctor's appointment I have ever made, has been a negation between me and the receptionist, as I'm leaving the exam room. In other words, I tell them when the doctor want's to see me, or in some cases the Doctor will tell them, and the whoever is scheduling the actual appointment will toss out times and dates within the time frame suggested by the doctor, and we settle on a time and date.

I can think of other needs here, but without addition information about the end result by Stevireno, it would be fruitless for us to be guessing.

Lee

  • Author

Maybe this will clarify, we send out postcards annually(sometimes sooner) to remind people of their routine exams, we don't schedule them as they leave one routine exam for another a year out.

I just need the calculation to move the number of months up by X months, the actual date is not a concern, I just need the field to show any date within the 3rd, 6th, 12th, 24th month in the future from the current month. Sorry for my vague request, I am a little new at this!

If you are going to quote me, make sure you keep it in content. :

Because, every doctor's appointment I have ever made, has been a negation between me and the receptionist, as I'm leaving the exam room

Lee

You didn't do anything wrong.

You have a choice of calculations, either of which will do what you have described as your need.

Lee

You can tell them all you want that both calcs will produce the same results but that will NEVER make it so.

I never said that both calculations produce the same result.

In fact, if you had looked at the example file I posted for Stevireno, you would see that I gave examples of both calculations, three scripts, and three calculation fields, just so that [color:orange]Stevireno could see the difference

Lee

Thanks for your correction, the nested function you proposed is much more elegant than the +365 with CASE to handle leap years that I had proposed! It's interesting to read these forums as I'm always learning new things.

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.