0

How can I convert SQL smalldatetime or datetime like this:

select cast(getdate() as smalldatetime)

To JSON format like this:

/Date(1576278000000+0100)/
3
  • why do you need to cast(getdate() as datetime) ? getdate() returns datetime data type Commented May 15, 2020 at 2:31
  • 1
    Perhaps you need to generate this UNIX timestamp with a statement like: SELECT CONCAT('/Date(',DATEDIFF_BIG(ms, DATEFROMPARTS(1970, 1, 1), GETDATE()), ')/') AS DateTime. Commented May 15, 2020 at 6:35
  • 1
    Looks good, just need to add time offset? Commented May 15, 2020 at 10:12

1 Answer 1

0

I just find this post in another issue like you got it. Maybe it would work for you

"render": function ( data, type, row ) {
  var fecha = new Date(parseInt(data.match(/\d+/)[0]));                
  return fecha.getMonth() + 1 + '/' + fecha.getDate() + '/' + fecha.getFullYear();;
 },
 "targets": 0

and this is the link that I found https://es.stackoverflow.com/questions/125686/convertir-fecha-en-javascript

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.