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.

Making a Case statement work for Overdue jobs.

Featured Replies

I am creating a database for a Landscape contractor business. ( my brother's )

I have Job table with a "date_start_job" field, a "date_end_job" field, and also a "duration_job" calculation field which is ( "date_start_job" - "date_end_job" ) .

There is also a number field called "estimate_duration_job".

What I want to do is have a message appear that shows all jobs which are overdue.

Overdue jobs are jobs where the "date_end job" is bigger than the ("date_start_job" + "estimate_duration_job") but also

where the current date is bigger than ("date_start_job" + "estimate_duration_job")

I created the following calc. but unfortunately it doesn't do the job. My problem is that I can get it to calculate if the "date_end_job" is populated, but if this field is empty it will not calculate. See calculation :

Case ( duration_job > duration_estimate_job ;

"This Job has overrun by " & duration_job - duration_estimate_job & " " & "Days" ;

)

I tried this other calculation and got wrong results as well :)

Case (

IsEmpty ( date_end_job ) ;

and

(date_start_job + duration_estimate_job ;> ( Get ( CurrentDate );

"This Job has overrun by " & duration_job - duration_estimate_job & " " & "Days"

)

) )

Any help is greatly welcomed.

Edited by Guest

Try:

Let ( [

end = Case ( date_end_job ; date_end_job ; Get (CurrentDate) ) ;

dur = end - date_start_job

] ;

Case (

dur > duration_estimate_job ;

"This job has overrun by " & dur - duration_estimate_job & " days"

)

)

---

Make sure the calculation is unstored, so that it updates with current date.

Edited by Guest

  • Author

Thank you very much for your reply. I am realy gratefull for your help. It worked like a charm.

Let ( [

jobDone = NOT IsEmpty ( date_end_job ) ;

daysOver = Case ( jobDone; date_end_job - date_start_job - estimate_duration_job ; Get ( CurrentDate ) - date_start_job - estimate_duration_job )

] ;

Case ( daysOver > 0 ; "This Job " &

Case ( jobDone ; "has overrun " ; "is overrunning " ) & "by " & daysOver & " Day" & Case ( daysOver > 1 ; "s" )

)

)

Edited by Guest

That's what happens when I take break before responding! Well, I'm leaving mine, Michael, because yours doesn't display nicely if there is only 1 day. ROFLMAO!!

UPDATE: Oh, and I ditched the calculation of actual duration because I suspected it wasn't necessary by itself and I dislike calcs whose only purpose is to be used in another calc. I might be wrong here however ...

2ND UPDATE: And Michael's calc is prettier in general but I would certainly correct the text portion. :wink2:

Edited by Guest
Added update and then 2nd update

  • Author

Thank you for trying to help, but the calc. :

Let ( [

jobDone = NOT IsEmpty ( date_end_job ) ;

daysOver = Case ( jobDone; date_end_job - date_start_job ; Get ( CurrentDate ) - date_start_job - estimate_duration_job )

] ;

Case ( daysOver > 0 ; "This Job " &

Case ( jobDone ; "has overrun " ; "is overrunning " ) & "by " & daysOver & " Day" & Case ( daysOver > 1 ; "s" )

)

)

didn't realy work, because it seems to ignore the end date when this is entered.

I had corrected my calc. YOu might check it again. :wink2:

Comment's calc is actually better but I wouldn't want to modify his to include my text result (which I think IS better). :blush2:

Edited by Guest

  • Author

I have attached a copy of the DB for you to check is you could. The calc doesn't seem to update.

Thank you for your help.

No attachment? I'll attach mine. I suspect that you missing this part:

Make sure the calculation is unstored, so that it updates with current date.

I suppose I should have repeated it but when I saw it on his calc, I assumed you understood that, since Get ( CurrentDate ) was in the calculation, it would need to be unstored.

If I'm still missing something, please let us know. :wink2:

Jobs.zip

  • Author

You are completely right of course. Thank you! It works beautifuly.

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.