Welcome, Guest
Username: Password: Remember me

TOPIC: What date-related functionality do users want?

What date-related functionality do users want? 3 years 4 months ago #63322

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
I'm planning to extend ExpressionManager to support dates and date-related math. In addition to regular comparison operators (>,>=,<,<=,==,!=), I expect to support at least the following set of functions (since I have customers who used a Java-based survey system with those functions and need to port over to LimeSurvey).
NameSyntaxDescription
formatDateformatDate(X,PAT)return the string value of date X formatted according to Java data format pattern PAT
getNowgetNow()returns the date corresponding to the current system time (if the computer clock is accurate)
getStartTimegetStartTime()returns the date corresponding to the system time when the interview was started
isDateisDate(X)returns true if the answer happens to be a valid date
newDatenewDate(W)
newDate(S,M)
newDate(Y,M,D)
returns a date corresponding to day of the week W (1 = Sunday, 2 = Monday, ...)
returns a date corresponding to string S as parsed by date mask M
returns a date corresponding to year Y, month M, and day D
newTimenewTime(S,M)
newTime(H,M,S)
returns a date/time corresponding to string S as parsed by time mask M
returns a date/time corresponding to hour H, minutes M, and seconds S
parseDateparseDate(X,PAT)returns the date value of string X parsed with Java date format pattern PAT
toDatetoDate(X)returns the answer for node X, as a date if possible, otherwise returns *INVALID*
toDaytoDay(X)returns the day components of X if possible, otherwise returns *INVALID*
toDayNumtoDayNum(X)returns the day number components of X (day of the year) if possible, otherwise returns *INVALID*
toHourtoHour(X)returns the hour component of X
toMinutetoMinute(X)returns the minute component of X if possible, otherwise returns *INVALID*
toMonthtoMonth(X)returns the month component of X if possible, otherwise returns *INVALID*
toMonthNumtoMonthNum(X)returns the month number (1-12) component of X if possible, otherwise returns *INVALID*
toSecondtoSecond(X)returns the seconds component of X if possible, otherwise returns *INVALID*
toTimetoTime(X)returns X as a time value (hh:mm:ss) if possible, otherwise returns *INVALID*
toWeekdaytoWeekday(X)returns the weekday component of X if possible (e.g. 'Monday'), otherwise returns *INVALID*
toYeartoYear(X)returns the year component of X if possible, otherwise returns *INVALID*

What other date-related functions has the community been asking for?

Also, do people have strong opinions on how to implement this technically?

The way I did this in the past was to support weak data typing, but store most answers in text fields. If the value happened to be a number, then numerical operators on it would make sense. Similarly, if the value happened to be a date, then you could do date-related functions.
The administrator has disabled public write access.

Re: What date-related functionality do users want? 3 years 4 months ago #63325

  • claudio123
  • claudio123's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 31
  • Thank you received: 1
  • Karma: 0
Tom,

I could not really think about additional requests regarding date and time - you explored about any possibility, I think.
I recently used some date/time function in a question where I tried to paste the actual data in a textfield that could be overwritten and discovered some strange behavior desribed in this thread:
http://limesurvey.org/en/forum/can-i-do-this-with-limesurvey/63091-pre-fill-textfield
Strange, because
- it only works if the number of rows of the textfield is described
- $(document).ready(function() { must not cover the complete script but is required for part of it.

Back to a bit more on-topic:
The way limesurvey allows to input date now is somewhat tricky, specially when using a pad. Dropdown boxes might be easier to use, but that's just a question of the designer of the survey, so not really on-topic here, I admit.

Thanks, nothing more to date/time ...

Claudio
... lost in brackets ...
(I suggest a preview option for posting in the forum)
The administrator has disabled public write access.

Aw: Re: What date-related functionality do users want? 3 years 4 months ago #63345

  • jelo
  • jelo's Avatar
  • OFFLINE
  • Platinum Lime
  • Posts: 470
  • Thank you received: 52
  • Karma: 16
claudio123 wrote:
I could not really think about additional requests regarding date and time - you explored about any possibility, I think.
That's the problem with many posts of TMSWhite. They're well-elaborated and need to think long and hard to find something useful to add. The only chance is to stay off-topic like me. The expression manager looks impressive. A lot of workarounds will be needless. tpartner will be grieving about the javascript workarounds gone :-)
Last Edit: 3 years 4 months ago by jelo.
The administrator has disabled public write access.

Re: Aw: Re: What date-related functionality do users want? 3 years 4 months ago #63346

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2949
  • Thank you received: 377
  • Karma: 124
@Jelo: I doubt that tpartner will be grieving. He'll be challenged with new and different tasks by the users soon, but the boring and repeating ones will be gone. ;-)
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Last Edit: 3 years 4 months ago by holch.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.141 seconds
Donation Image