Getting a constant today's date

While there might not be a ton of ways to use this, I found myself wanting a way to get today’s date in case I needed to compare it to something else. However, this functionality wasn’t present natively in a way that worked for the way I wanted it.

If you take the simplest, most direct approach, you’d include a date question, label it “Today’s date” or something, and toggle the default to be today’s date. However, this shows the respondent the extraneous question. You also don’t want them to modify that date if you’re counting on it to be set to today’s date since today can never change, really. But, there’s no read-only option on a date question like there is with a price question.

So, I figured out a way to make it hidden by tricking the visibility logic and giving me my artificial hidden, read-only date that always read today.

You can check it out, along with a small write-up as to how it works:
https://datetoday.paperform.co/

5 Likes

Nice workaround and write up.

I just wonder why the time stamp added automatically to each submission would not be enough? I may be missing something.

1 Like

I originally fleshed this idea out due to a user’s request to calculate the amount of days from today until the date selected by the user from a date question. They wanted to do something with that value.

My first thought was to use a calculation using DATEDIFF(). The problem with that was that it required a proper date to work. I couldn’t very well just say, “Hey, compare ‘today’ and ‘04-09-2020’.” It has no idea what “today” is. The alternative, then, would be to include a date question that defaults to “today” and then use its value in the difference function.

The next problem was: well, if the respondent can see the date question for “today,” then they can alter it. If we’re trying to calculate the difference between today and some other date, we can’t very well have today change. But, if we hide today’s date and are still able to pull its value, we’re set.

They wanted this all to be done in-form, so I couldn’t use submission data. Even if I could use submission data, I’d still need to instruct them on how to pass that data to a function somewhere outside the platform since figuring out the amount of days manually really isn’t in the spirit of answer piping, pre-filling, and integrations.

So, this seemed the most optimal solution for their needs. Admittedly, this probably won’t be widely used. But, if one needs to, it’s there.

5 Likes

I was right that I was missing something. It does make sense now. :slight_smile:
Thanks for sharing!

3 Likes

Update: You can now use NOW() in calculations to grab the date and time from when the form was loaded. No workaround required.

:sunglasses:

1 Like

:clap: :clap: @danny @dean @Josh you guys rock :slight_smile:

2 Likes

Thank you for sharing this :slightly_smiling_face:
After your work… I was able to use the calculation field that worked better on my case, this is what I used of pulling today date in the format I wonted…

DATEFORMAT(NOW(), “DD/MM/YYYY”)
or
DATEFORMAT(NOW(), “HH:mm DD/MM/YYYY”)

if you want the time as well.

2 Likes

I’m a fan of Zapier and like how easy it is to do the time calculations there using their date formatter.

3 Likes