Skip to content
Advertisement

Save datetime in sql table

How I can insert with a query a date like this? 2015-06-02T11:18:25.000

I have tried this:

But I have returned:

I tried also:

but it is not working:

The entire query is:

What is wrong?

Advertisement

Answer

Try this:

126 relates to ISO8601, which is the format yyyy-mm-ddThh:mi:ss.mmm.

This is the same format as the string '2015-06-02T11:18:25.000'.

For more information, see here.

For dates with a datetimeoffset (for example '2015-06-02T11:14:06+02:00' – note the +02:00 at the end), you will have to do this:

The fully fixed query should be:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement