Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

SOLVED: Invalid date format error on Date/Time with Default Answer

  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 1 month ago #212927 by blocka
I have a survey with a data/time question type that I want to prepopulate with current date and time. 

So, in Default Answer I input: 
{date('d/m/Y H:i')}

I have the Date/Time Format for the question set to  dd.mm.yyyy HH:MM

When the survey loads, I get the error: 

500: Internal Server Error
CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '04/03/2021 19:13'

If I remove the Default answer value, the error disappears (but then my date field isn't pre-populated with date time. 

Please see attached survey -- Q68... I wonder what I'm doing wrong?
The topic has been locked.
  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 1 month ago #212928 by blocka
I changed Default answer to:

{date('Y/m/d H:i')}
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 years 1 month ago #212935 by DenisChenu
I think you must use SQL/ISO format for default date.

It's done without using datetime format of the question. It work with 'Y/m/d H:i', bnut think best is to use 'Y-m-d H:i'

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose