# Use yesterday's date in form, dependency error

201
4
03-25-2024 03:45 AM
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))

Tags (3)
1 Solution

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

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

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.

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)

New Contributor II

Thank you. That worked!