How to constrain the dates inputs?

Hi,

I wonder if this is possible to constrain month and year in the type of "date" field to be only in April and May of 2015, as this is the period for data collection, so that enumerator won't be able to get absurd dates?
Thank you!

Best,
E

Try it.

ยทยทยท On Fri, Apr 10, 2015 at 12:17 PM, wrote:

Hi,

I wonder if this is possible to constrain month and year in the type of
"date" field to be only in April and May of 2015, as this is the period for
data collection, so that enumerator won't be able to get absurd dates?
Thank you!

Best,
E

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Hey,

I used

(format-date(decimal-date-time(${test_date}), '%Y')) <= (format-date(now(),
'%Y'))

as a constraint for people selecting their test dates and this prevents the
date selection being in the future (taking into account only the last two
digits of the year. So the RHS should read '15' at the time of this post.
But if if you want other constraints then you can mess about with the
above.

Seemed to do the trick!

Hope that helps,

Sachin

ยทยทยท On Friday, 10 April 2015 21:17:38 UTC+2, Eva Q wrote: > > Hi, > > I wonder if this is possible to constrain month and year in the type of > "date" field to be only in April and May of 2015, as this is the period for > data collection, so that enumerator won't be able to get absurd dates? > Thank you! > > Best, > E

p.s. you can add in month options into the 'format-date' option as well
(see below). Still not sure why quite how the decimal-date-time conversion
happens so you need to experiment a bit to get the month feature right. Let
me know if you have any success - would be good to see how you did it.

best,

Sachin

Returns the date value formatted as defined by the format argument using
the following identifiers:
%Y: 4-digit year
%y: 2-digit year
%m 0-padded month
%n numeric month
%b short text month (Jan, Feb, etc)
%d 0-padded day of month
%e day of month
%H 0-padded hour (24-hr time)
%h hour (24-hr time)
%M 0-padded minute
%S 0-padded second
%3 0-padded millisecond ticks
%a short text day (Sun, Mon, etc)

ยทยทยท On Monday, 13 April 2015 12:23:45 UTC+2, Sachin wrote: > > Hey, > > I used > > (format-date(decimal-date-time(${test_date}), '%Y')) <= > (format-date(now(), '%Y')) > > as a constraint for people selecting their test dates and this prevents > the date selection being in the future (taking into account only the last > two digits of the year. So the RHS should read '15' at the time of this > post. But if if you want other constraints then you can mess about with the > above. > > Seemed to do the trick! > > Hope that helps, > > Sachin > > On Friday, 10 April 2015 21:17:38 UTC+2, Eva Q wrote: >> >> Hi, >> >> I wonder if this is possible to constrain month and year in the type of >> "date" field to be only in April and May of 2015, as this is the period for >> data collection, so that enumerator won't be able to get absurd dates? >> Thank you! >> >> Best, >> E > >
1 Like