Datatable editor DateTime format conversion
Datatable editor DateTime format conversion
Pignattino
Posts: 10Questions: 2Answers: 0
I'm using formatters in my controller to set a date string format into DateTime sql data… the field is set as following in VB.net
.Field(New Field("OrdiniGiornaliero.RitiroDopo") _
.GetFormatter(Format.DateSqlToFormat("dd/MM/yyyy HH:mm")) _
.SetFormatter(Format.DateTime("dd/MM/yyyy HH:mm"))) _
when reading data everything is correct.. display data in the format I want… when update data an error occurred
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated
so cannot convert string date and time to a dataTime valid format for database….
if I set the formatter with
.SetFormatter(Format.DateFormatToSql("dd/MM/yyyy HH:mm"))) _
saves only date but not time…..
any idea?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Are you using a model? If so can you try using "OrdiniGiornaliero.RitiroDopo" as a string please.
Allan
It is a string
Actually I just saw in your e-mail on this same topic that you are using a string.
The
Format.DateTime
method takes two parameters - afrom
andto
(I'm slightly surprised it isn't giving a compile error if only one is passed actually). Could you give it a second parameter in the ISO8601 format please.Allan
the second parameter is optional.. I've tried also with constant values like iso8601 (it is a constant string that posto only a date.. not with a time value...)
if this function Format.DateTime(from, to) convert a string date format to another, what is it useful for??
anyway.... it doesn't work :(
It is optional but its a little redundant since if you leave
to
asnull
then it will take the value of thefrom
parameter.You need to use something like:
Allan
the thing weird is that seems to confuse months with days in the dd/MM/yyyy HH:ss format... and using format.DateTime with only one parameter...
because if I set 12/12/2016 12:00 it works.... and if I set 02/12/2016 12:00 and I reopen the calendar, it sets February 12th........ and if I set 13/12/2016 12:00 have an error....
This can help you?
How have you configured it on the client-side?
Allan
ok allan.. found the way!
as you suggested...
Format.DateTime("dd/MM/yyyy HH:mm", "yyyy-MM-dd HH:mm:ss")
previously I didn't put seconds in "to" date... because my date doesn't have it...
with seconds works!
thanks!!!