Conversion date javascript to sqlserver

Asked

Viewed 101 times

0

I am trying to save a field of type date in the SQLSERVER database, however it does not insert, is returning me the following error:

Sequence not recognized as valid datetime.

DateTime dat = DateTime.ParseExact(txtVencimentoC.Text, "dd/MM/yyyy", null);
cadastrocontasreceber.Vencimento = dat;

I tried this way, and several others, but all return me the error. As I am doing the sum of dates by javascript, the field is of this format "Sun Nov 19 2017 00:00:00 GMT-0200 (Brazilian daylight saving time)" How can I format it to Datetime in Sqlserver, or how can I set it inside javascript by going to the already formatted txtVencimentC? For all forms return me the same error. I thank you.

  • 1

    I don’t know if it will work, but try to convert this date to timestamp and then send it to sql. See here how to generate the timestamp: https://stackoverflow.com/questions/9873197/convert-date-to-timestamp-in-javascript

1 answer

0


I used this link as a reference. It was like this in the code:

document.getElementById("<%= txtVencimentoC.ClientID %>").value = data.format("dd/MM/yyyy HH:mm:ss");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.