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.

days in residence in month

Featured Replies

  • Newbies

Hi, I have been trying to figure this out for a while. Using FM 5.5, Windows. I have created a homeless shelter resident tracking system.

Among the fields are "datein" and "dateout". I need to run reports monthly showing how many days the residents were here in that month. THere are residents that were there all month, some that came in during the month and left in that month and others that came in during the month and left either the next month or are still here. The date out may be empty if the resident is still here. So, for each resident that was here in the month, I need to determine how many days the resident was here.

i.e.,

J. Smith - 5

B. Smith - 21

G. Jones - 30

I want to set this up so I can do this every month and eventually do annual reports.

Sorry for the length of posting and thanks in advance for any help

Peter

Let's say you have a number field, ReportMonth

Calculate the FirstDay of the ReportMonth:

Date( Month(ReportMonth), 1, Year(ReportYear))

Calculate the LastDay of the ReportMonth:

Date(Month(ReportMonth) + 1, 0, Year(ReportYear))

## That's a fun way of doing it that I credit to Djukic Goran.

The less evil way would be:

Date(Month(ReportMonth) + 1, 1, Year(ReportYear)) - 1

First you'll need to find everyone, you can script this:

Request1: datein =< LastDay / dateout => FirstDay

Request2: datein =< LastDay / dateout = "" (blank)

Hint: Set Field doesn't work very well when scripting date finds. Use Insert Calculated Result, but make sure the script goes to a layout that the datein and dateout fields are on.

Then you'll have to test for a number of possibilities with a Case() calculation -- calculate the End Date first, then subtract the Start Date:

Case(dateout < LastDay and not IsEmpty(dateout), dateout, LastDay) -

Case(datein < FirstDay, FirstDay, datein) + 1

The plus one is there because I assume if someone checks in and out the same day you count it as one day, not zero.

Don't worry about the length of your post, I thought it was clear and concise. I've seen a lot worse!

  • Author
  • Newbies

Tom,

Thank you (belated) - I'm working on it

Thanks for the quick reply

Peter

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.