Hi, I have a problem using SurveyJs, through the Designer tab. My recording json, in the date field (field in date format), saves the date in the database in the format YYYY/MM/DD, Example: 2025-10-29. When I use my other form, which has the function of loading and displaying this data from the database, for the user, it ends up SUBTRACTING, subtracting 1 day from the date, for example: 10/28/2025 (PT-BR format). If I leave it in the YYYY-MM-DD format it works correctly, but I need it to be in the PT-BR format (DD/MM/YYYY). I used the field in the date format and set the display format to date, but it subtracts 1 day from the date. If I disable the display format, it does not subtract, the date remains correct, but in the format that I cannot use, I need DD/MM/YYYY. Then I went for another approach, working with the date with a text field, and using a mask, to force the data to be saved in the database as DD/MM/YYYY, but the result is the same, it always ends up decreasing 1 day from the date. The question is, I need the date to be displayed to the user to be DD/MM/YYYY, but all the ways through surveyJS Designer (I can only do it through it), end up decreasing 1 day from the date. Can someone help me and explain why this happens? The database is SQL SERVER. The data is being saved correctly, the problem is in the display, when it is going to be shown to the user.
json recording
JSON{
"pages": [
{
"name": "page1",
"elements": [
{
"type": "panel",
"name": "refracao",
"questionTitleLocation": "top",
"title": "Auto Refração",
"showQuestionNumbers": "off",
"elements": [
{
"type": "text",
"name": "DATE_LIBERACAO",
"title": "Data de Liberação",
"maskType": "datetime",
"maskSettings": {
"saveMaskedValue": true,
"pattern": "dd/mm/yyyy"
}
},
{
"type": "text",
"name": "TIME_LIBERACAO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Hora de Liberação",
"inputType": "time"
},
{
"type": "text",
"name": "VL_ARD_DP",
"minWidth": "150px",
"title": "DP"
},
{
"type": "html",
"name": "question3",
"minWidth": "150px",
"html": "<strong>Auto Refração Dinâmica</strong>\n"
},
{
"type": "boolean",
"name": "IE_RECEITA_DINAMICA",
"minWidth": "150px",
"startWithNewLine": false,
"title": {
"default": " ",
"pt-br": "Receita"
},
"titleLocation": "left",
"defaultValueExpression": "false",
"labelTrue": {
"pt-br": "Sim"
},
"labelFalse": {
"pt-br": "Não"
},
"valueTrue": "Sim",
"valueFalse": "Não"
},
{
"type": "html",
"name": "question7",
"minWidth": "80px",
"html": "<p class='titFormReceitaOculos'><strong>OD</strong></p>"
},
{
"type": "text",
"name": "VL_OD_ARD_ESF",
"minWidth": "150px",
"title": "DE:"
},
{
"type": "text",
"name": "VL_OD_ARD_CIL",
"minWidth": "150px",
"startWithNewLine": false,
"title": "DC:"
},
{
"type": "text",
"name": "VL_OD_ARD_EIXO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Eixo:"
},
{
"type": "text",
"name": "VL_OD_ARD_AV_SC",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Reflexo OD:"
},
{
"type": "html",
"name": "question8",
"minWidth": "80px",
"html": "<p class='titFormReceitaOculos'><strong>OE</strong></p>"
},
{
"type": "text",
"name": "VL_OE_ARD_ESF",
"minWidth": "150px",
"title": "DE:",
"titleLocation": "top"
},
{
"type": "text",
"name": "VL_OE_ARD_CIL",
"minWidth": "150px",
"startWithNewLine": false,
"title": "DC:",
"titleLocation": "top"
},
{
"type": "text",
"name": "VL_OE_ARD_EIXO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Eixo:",
"titleLocation": "top"
},
{
"type": "text",
"name": "VL_OE_ARD_AV_SC",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Reflexo OE:",
"titleLocation": "top"
},
{
"type": "html",
"name": "question4",
"minWidth": "150px",
"html": "<strong>Auto Refração Estática</strong>"
},
{
"type": "boolean",
"name": "IE_RECEITA_ESTATICA",
"minWidth": "150px",
"startWithNewLine": false,
"title": {
"default": "\n",
"pt-br": "Receita"
},
"titleLocation": "left",
"defaultValueExpression": "false\n",
"labelTrue": {
"pt-br": "Sim"
},
"labelFalse": {
"pt-br": "Não"
},
"valueTrue": "Sim",
"valueFalse": "Não"
},
{
"type": "html",
"name": "question5",
"html": "<strong>OD</strong>\n"
},
{
"type": "text",
"name": "VL_OD_ARE_ESF",
"minWidth": "150px",
"title": "DE:"
},
{
"type": "text",
"name": "VL_OD_ARE_CIL",
"minWidth": "150px",
"startWithNewLine": false,
"title": "DC:"
},
{
"type": "text",
"name": "VL_OD_ARE_EIXO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Eixo:"
},
{
"type": "text",
"name": "VL_OD_ARE_AV_SC",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Reflexo OD:"
},
{
"type": "html",
"name": "question6",
"html": "<strong>OE</strong>\n"
},
{
"type": "text",
"name": "VL_OE_ARE_ESF",
"minWidth": "150px",
"title": "DE:"
},
{
"type": "text",
"name": "VL_OE_ARE_CIL",
"minWidth": "150px",
"startWithNewLine": false,
"title": "DC:"
},
{
"type": "text",
"name": "VL_OE_ARE_EIXO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Eixo:"
},
{
"type": "text",
"name": "VL_OE_ARE_AV_SC",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Reflexo OE:"
},
{
"type": "comment",
"name": "DS_OBSERVACAO",
"title": "Observação:"
},
{
"type": "boolean",
"name": "IE_SITUACAO",
"title": {
"default": " ",
"pt-br": "Ativo"
},
"titleLocation": "left",
"defaultValueExpression": "false\n",
"labelTrue": {
"pt-br": "Sim"
},
"labelFalse": {
"pt-br": "Não"
},
"valueTrue": "Sim",
"valueFalse": "Não"
}
]
}
]
}
]
}
reading json
JSON{
"locale": "pt-br",
"pages": [
{
"name": "page1",
"elements": [
{
"type": "panel",
"name": "refracao",
"questionTitleLocation": "top",
"title": "Auto Refração",
"showQuestionNumbers": "off",
"elements": [
{
"type": "expression",
"name": "DATE_LIBERACAO",
"minWidth": "150px",
"title": {
"pt-br": "Data de Liberação"
}
},
{
"type": "expression",
"name": "TIME_LIBERACAO",
"minWidth": "150px",
"startWithNewLine": false,
"title": {
"pt-br": "Hora de Liberação"
}
},
{
"type": "expression",
"name": "VL_ARD_DP",
"minWidth": "150px",
"title": "DP"
},
{
"type": "html",
"name": "question3",
"minWidth": "150px",
"html": "<strong>Auto Refração Dinâmica</strong>\n"
},
{
"type": "expression",
"name": "IE_RECEITA_DINAMICA",
"minWidth": "150px",
"startWithNewLine": false,
"title": {
"default": "\n",
"pt-br": "Receita"
},
"titleLocation": "left"
},
{
"type": "html",
"name": "question7",
"minWidth": "80px",
"html": "<p class='titFormReceitaOculos'><strong>OD</strong></p>"
},
{
"type": "expression",
"name": "VL_OD_ARD_ESF",
"minWidth": "150px",
"title": "DE:"
},
{
"type": "expression",
"name": "VL_OD_ARD_CIL",
"minWidth": "150px",
"startWithNewLine": false,
"title": "DC:"
},
{
"type": "expression",
"name": "VL_OD_ARD_EIXO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Eixo:"
},
{
"type": "expression",
"name": "VL_OD_ARD_AV_SC",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Reflexo OD:"
},
{
"type": "html",
"name": "question8",
"minWidth": "80px",
"html": "<p class='titFormReceitaOculos'><strong>OE</strong></p>"
},
{
"type": "expression",
"name": "VL_OE_ARD_ESF",
"minWidth": "150px",
"title": "DE:",
"titleLocation": "top"
},
{
"type": "expression",
"name": "VL_OE_ARD_CIL",
"minWidth": "150px",
"startWithNewLine": false,
"title": "DC:",
"titleLocation": "top"
},
{
"type": "expression",
"name": "VL_OE_ARD_EIXO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Eixo:",
"titleLocation": "top"
},
{
"type": "expression",
"name": "VL_OE_ARD_AV_SC",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Reflexo OE:",
"titleLocation": "top"
},
{
"type": "html",
"name": "question4",
"minWidth": "150px",
"html": "<strong>Auto Refração Estática</strong>"
},
{
"type": "expression",
"name": "IE_RECEITA_ESTATICA",
"minWidth": "150px",
"startWithNewLine": false,
"title": {
"default": "\n",
"pt-br": "Receita"
},
"titleLocation": "left"
},
{
"type": "html",
"name": "question5",
"html": "<strong>OD</strong>\n"
},
{
"type": "expression",
"name": "VL_OD_ARE_ESF",
"minWidth": "150px",
"title": "DE:"
},
{
"type": "expression",
"name": "VL_OD_ARE_CIL",
"minWidth": "150px",
"startWithNewLine": false,
"title": "DC:"
},
{
"type": "expression",
"name": "VL_OD_ARE_EIXO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Eixo:"
},
{
"type": "expression",
"name": "VL_OD_ARE_AV_SC",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Reflexo OD:"
},
{
"type": "html",
"name": "question6",
"html": "<strong>OE</strong>\n"
},
{
"type": "expression",
"name": "VL_OE_ARE_ESF",
"minWidth": "150px",
"title": "DE:"
},
{
"type": "expression",
"name": "VL_OE_ARE_CIL",
"minWidth": "150px",
"startWithNewLine": false,
"title": "DC:"
},
{
"type": "expression",
"name": "VL_OE_ARE_EIXO",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Eixo:"
},
{
"type": "expression",
"name": "VL_OE_ARE_AV_SC",
"minWidth": "150px",
"startWithNewLine": false,
"title": "Reflexo OE:"
},
{
"type": "expression",
"name": "DS_OBSERVACAO",
"title": "Observação:"
},
{
"type": "expression",
"name": "IE_SITUACAO",
"title": {
"default": " ",
"pt-br": "Ativo"
},
"titleLocation": "left"
}
]
}
]
}
]
}
Hello Michael,
If you use a Text field with the date input type, SurveyJS uses the standard
input type="date"
HTML element. As outlined in MDN, a value of such a field is normalized to the formatyyyy-mm-dd
.When you enable the "date" mask, a Text field value is also saved using the following format:
yyyy-mm-dd
.However, if you enable the
saveMaskedValue
option, the value will be saved in a format defined by the mask pattern, e.g.,"29/10/2025
.For us to move forward and research the issue, we need to get further details about your usage scenario.
I look forward to your reply.
Hello Jane,
Hello, I'll try to give you more examples.
When I run the tests using the Survey preview, the results are as expected, everything is fine.
Then I generate the json with the form to save the data in our database, and I generate the json with the form that will receive the data from the database and display it to the user (this json is just an expression). So far so good, I open the form with the mask dd/mm/yyyy (for example 29/10/2025) and this data is saved in our database (sql server). When I check this data, if it is being saved correctly in the database, it is correct, 29/10/2025. But when the json of the display form (expression) is activated, it ends up decreasing 1 day, displaying 10/28/2025. The issue is, the form with the date field, or text with a mask for dd/mm/yyyy is saving within the database correctly, the database stores it in the correct format, but when displaying it in the expression form, it always displays it with one day less than it should. I will send more prints, of use cases, to exemplify.
json that saves the data in the database
{ "pages": [ { "name": "page1", "elements": [ { "type": "panel", "name": "refracao", "questionTitleLocation": "top", "title": "Auto Refração", "showQuestionNumbers": "off", "elements": [ { "type": "text", "name": "DATE_LIBERACAO", "title": "Data de Liberação", "maskType": "datetime", "maskSettings": { "saveMaskedValue": true, "pattern": "dd/mm/yyyy" } }, { "type": "text", "name": "TIME_LIBERACAO", "minWidth": "150px", "startWithNewLine": false, "title": "Hora de Liberação", "inputType": "time" }, { "type": "text", "name": "VL_ARD_DP", "minWidth": "150px", "title": "DP" }, { "type": "html", "name": "question3", "minWidth": "150px", "html": "<strong>Auto Refração Dinâmica</strong>\n" }, { "type": "boolean", "name": "IE_RECEITA_DINAMICA", "minWidth": "150px", "startWithNewLine": false, "title": { "default": " ", "pt-br": "Receita" }, "titleLocation": "left", "defaultValueExpression": "false", "labelTrue": { "pt-br": "Sim" }, "labelFalse": { "pt-br": "Não" }, "valueTrue": "Sim", "valueFalse": "Não" }, { "type": "html", "name": "question7", "minWidth": "80px", "html": "<p class='titFormReceitaOculos'><strong>OD</strong></p>" }, { "type": "text", "name": "VL_OD_ARD_ESF", "minWidth": "150px", "title": "DE:" }, { "type": "text", "name": "VL_OD_ARD_CIL", "minWidth": "150px", "startWithNewLine": false, "title": "DC:" }, { "type": "text", "name": "VL_OD_ARD_EIXO", "minWidth": "150px", "startWithNewLine": false, "title": "Eixo:" }, { "type": "text", "name": "VL_OD_ARD_AV_SC", "minWidth": "150px", "startWithNewLine": false, "title": "Reflexo OD:" }, { "type": "html", "name": "question8", "minWidth": "80px", "html": "<p class='titFormReceitaOculos'><strong>OE</strong></p>" }, { "type": "text", "name": "VL_OE_ARD_ESF", "minWidth": "150px", "title": "DE:", "titleLocation": "top" }, { "type": "text", "name": "VL_OE_ARD_CIL", "minWidth": "150px", "startWithNewLine": false, "title": "DC:", "titleLocation": "top" }, { "type": "text", "name": "VL_OE_ARD_EIXO", "minWidth": "150px", "startWithNewLine": false, "title": "Eixo:", "titleLocation": "top" }, { "type": "text", "name": "VL_OE_ARD_AV_SC", "minWidth": "150px", "startWithNewLine": false, "title": "Reflexo OE:", "titleLocation": "top" }, { "type": "html", "name": "question4", "minWidth": "150px", "html": "<strong>Auto Refração Estática</strong>" }, { "type": "boolean", "name": "IE_RECEITA_ESTATICA", "minWidth": "150px", "startWithNewLine": false, "title": { "default": "\n", "pt-br": "Receita" }, "titleLocation": "left", "defaultValueExpression": "false\n", "labelTrue": { "pt-br": "Sim" }, "labelFalse": { "pt-br": "Não" }, "valueTrue": "Sim", "valueFalse": "Não" }, { "type": "html", "name": "question5", "html": "<strong>OD</strong>\n" }, { "type": "text", "name": "VL_OD_ARE_ESF", "minWidth": "150px", "title": "DE:" }, { "type": "text", "name": "VL_OD_ARE_CIL", "minWidth": "150px", "startWithNewLine": false, "title": "DC:" }, { "type": "text", "name": "VL_OD_ARE_EIXO", "minWidth": "150px", "startWithNewLine": false, "title": "Eixo:" }, { "type": "text", "name": "VL_OD_ARE_AV_SC", "minWidth": "150px", "startWithNewLine": false, "title": "Reflexo OD:" }, { "type": "html", "name": "question6", "html": "<strong>OE</strong>\n" }, { "type": "text", "name": "VL_OE_ARE_ESF", "minWidth": "150px", "title": "DE:" }, { "type": "text", "name": "VL_OE_ARE_CIL", "minWidth": "150px", "startWithNewLine": false, "title": "DC:" }, { "type": "text", "name": "VL_OE_ARE_EIXO", "minWidth": "150px", "startWithNewLine": false, "title": "Eixo:" }, { "type": "text", "name": "VL_OE_ARE_AV_SC", "minWidth": "150px", "startWithNewLine": false, "title": "Reflexo OE:" }, { "type": "comment", "name": "DS_OBSERVACAO", "title": "Observação:" }, { "type": "boolean", "name": "IE_SITUACAO", "title": { "default": " ", "pt-br": "Ativo" }, "titleLocation": "left", "defaultValueExpression": "false\n", "labelTrue": { "pt-br": "Sim" }, "labelFalse": { "pt-br": "Não" }, "valueTrue": "Sim", "valueFalse": "Não" } ] } ] } ] }
json that reads the data from the database and displays it to the user, expression form
{ "locale": "pt-br", "pages": [ { "name": "page1", "elements": [ { "type": "panel", "name": "refracao", "questionTitleLocation": "top", "title": "Auto Refração", "showQuestionNumbers": "off", "elements": [ { "type": "expression", "name": "DATE_LIBERACAO", "minWidth": "150px", "title": { "pt-br": "Data de Liberação" } }, { "type": "expression", "name": "TIME_LIBERACAO", "minWidth": "150px", "startWithNewLine": false, "title": { "pt-br": "Hora de Liberação" } }, { "type": "expression", "name": "VL_ARD_DP", "minWidth": "150px", "title": "DP" }, { "type": "html", "name": "question3", "minWidth": "150px", "html": "<strong>Auto Refração Dinâmica</strong>\n" }, { "type": "expression", "name": "IE_RECEITA_DINAMICA", "minWidth": "150px", "startWithNewLine": false, "title": { "default": "\n", "pt-br": "Receita" }, "titleLocation": "left" }, { "type": "html", "name": "question7", "minWidth": "80px", "html": "<p class='titFormReceitaOculos'><strong>OD</strong></p>" }, { "type": "expression", "name": "VL_OD_ARD_ESF", "minWidth": "150px", "title": "DE:" }, { "type": "expression", "name": "VL_OD_ARD_CIL", "minWidth": "150px", "startWithNewLine": false, "title": "DC:" }, { "type": "expression", "name": "VL_OD_ARD_EIXO", "minWidth": "150px", "startWithNewLine": false, "title": "Eixo:" }, { "type": "expression", "name": "VL_OD_ARD_AV_SC", "minWidth": "150px", "startWithNewLine": false, "title": "Reflexo OD:" }, { "type": "html", "name": "question8", "minWidth": "80px", "html": "<p class='titFormReceitaOculos'><strong>OE</strong></p>" }, { "type": "expression", "name": "VL_OE_ARD_ESF", "minWidth": "150px", "title": "DE:", "titleLocation": "top" }, { "type": "expression", "name": "VL_OE_ARD_CIL", "minWidth": "150px", "startWithNewLine": false, "title": "DC:", "titleLocation": "top" }, { "type": "expression", "name": "VL_OE_ARD_EIXO", "minWidth": "150px", "startWithNewLine": false, "title": "Eixo:", "titleLocation": "top" }, { "type": "expression", "name": "VL_OE_ARD_AV_SC", "minWidth": "150px", "startWithNewLine": false, "title": "Reflexo OE:", "titleLocation": "top" }, { "type": "html", "name": "question4", "minWidth": "150px", "html": "<strong>Auto Refração Estática</strong>" }, { "type": "expression", "name": "IE_RECEITA_ESTATICA", "minWidth": "150px", "startWithNewLine": false, "title": { "default": "\n", "pt-br": "Receita" }, "titleLocation": "left" }, { "type": "html", "name": "question5", "html": "<strong>OD</strong>\n" }, { "type": "expression", "name": "VL_OD_ARE_ESF", "minWidth": "150px", "title": "DE:" }, { "type": "expression", "name": "VL_OD_ARE_CIL", "minWidth": "150px", "startWithNewLine": false, "title": "DC:" }, { "type": "expression", "name": "VL_OD_ARE_EIXO", "minWidth": "150px", "startWithNewLine": false, "title": "Eixo:" }, { "type": "expression", "name": "VL_OD_ARE_AV_SC", "minWidth": "150px", "startWithNewLine": false, "title": "Reflexo OD:" }, { "type": "html", "name": "question6", "html": "<strong>OE</strong>\n" }, { "type": "expression", "name": "VL_OE_ARE_ESF", "minWidth": "150px", "title": "DE:" }, { "type": "expression", "name": "VL_OE_ARE_CIL", "minWidth": "150px", "startWithNewLine": false, "title": "DC:" }, { "type": "expression", "name": "VL_OE_ARE_EIXO", "minWidth": "150px", "startWithNewLine": false, "title": "Eixo:" }, { "type": "expression", "name": "VL_OE_ARE_AV_SC", "minWidth": "150px", "startWithNewLine": false, "title": "Reflexo OE:" }, { "type": "expression", "name": "DS_OBSERVACAO", "title": "Observação:" }, { "type": "expression", "name": "IE_SITUACAO", "title": { "default": " ", "pt-br": "Ativo" }, "titleLocation": "left" } ] } ] } ] }
Now I will send prints of the forms being used.
I will show you how the data is saved in the database.
Here:
{'IE_RECEITA_DINAMICA':'Sim','IE_RECEITA_ESTATICA':false,'IE_SITUACAO':false,'VL_ARD_DP':'test A3','DATE_LIBERACAO':'28/11/2025','VL_OD_ARD_ESF':'1'}
See? It was saved as 28/11/2025, which is expected, it saved correctly what I typed. in DATE_LIBERACAO: 28/11/2025
But in the form responsible for displaying it, the expression form, it displays one day less…
The data is saved correctly in the database… as expected
I sent a print of the surveyjs preview, where the field for entering the date is of the date type with a dd/mm/yyyy mask, and I added a field next to it to display the result, an expression type field
Could you help me solve this problem? I need the date displayed to be precise and equal to dd/mm/yyyy
Hello Jane,
I also noticed that if I apply the mask to the form that sends the data, before the data enters the database, it already decreases the date by 1 day, thus storing the date in the wrong value. In other words, if I apply some formatter, mask for text field, the data is SENT with 1 day less, if I use the display format to read the data in dd/mm/yyyy, it displays with 1 day less. But if I remove everything, leaving the natural data, it sends and displays correctly, but with the yyyy/mm/dd mask. Masks for text field remove 1 day, displayformat displays with -1 day. Without masks and display format it works, but in the formatting that does not suit me. Is there any other alternative that I can use to display dd/mm/yyyy?
Hello Michael,
Thank you for the update. I may need additional time to reply. Please stay tuned.
Hello Michael,
Thank your patience. Before you send a date value to your database, it's required to convert it to a UTC value. When you load dates from your database, it's necessary to convert them to local dates. This way you can ensure that a correct fate is always restored.
Regarding your additional comment:
I would appreciate it if you could share a demo which reproduces this issue. In particular, I need to see how exactly you obtain a date value which is different from the value specified in your form.
I look forward to your reply.