Select to view content in your preferred language

Use yesterday's date in form, dependency error

243
4
Jump to solution
03-25-2024 03:45 AM
JamieShinskie
New Contributor II

I'm trying to auto-populate a field using yesterday's date. I'm conducting a survey where we check a product twice. Once on a date and then the next day we recheck the product for differences. I have a select_one (${date_choice}) with two options, wakeup and holdover, and two date fields, a wakeup date (the first date) and a holdover date (next day).

I'm trying to auto-populate the wakeup date field, ${date_wake}, so that it populates today or yesterday based on the datechoice chosen. I can't find an easy option for yesterday, but I got to the expression below. I ran into a dependency cycle error and don't know what else to try. Can anyone help?

if(selected(${date_choice}, 'wakeup'), today(), if(selected(${date_choice}, 'holdover'), ${date_wake}<today(), 0))

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Weird I know today() - 1 works in constraints but it does not work for me in a calc.

This did work though   today() - (1000*24*60*60*1)

View solution in original post

0 Kudos
4 Replies
ChristopherCounsell
MVP Regular Contributor
  1. date_choice = wakeup or holdover
  2. date_wakeup =  if(selected(${date_choice}, 'wakeup'), today(), if(selected(${date_choice}, 'holdover'), ${date_wake}<today(), 0))

I assume date_wake in the function is date_wakeup and is referring to the own question? Shouldn't this be the alternate answer for holdover, i.e. today() - 1 day?

You've put in a constraint formula where you want something more like int(today()) -(1000*24*60*60)

0 Kudos
JamieShinskie
New Contributor II

I'm trying to teach myself this coding on the fly, and I don't understand what you mean. I tried using today() - 1 day in place of the bolded text and that did not work and I also tried to place the formula int(today()) -(1000*24*60*60) in the constraint column and that did not work.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Weird I know today() - 1 works in constraints but it does not work for me in a calc.

This did work though   today() - (1000*24*60*60*1)

0 Kudos
JamieShinskie
New Contributor II

Thank you. That worked!