0

How can I convert SQL smalldatetime or datetime like this:

select cast(getdate() as smalldatetime)

To JSON format like this:

/Date(1576278000000+0100)/
oguz ismail
  • 1
  • 16
  • 47
  • 69
hoggar
  • 3,699
  • 5
  • 31
  • 41
  • why do you need to `cast(getdate() as datetime)` ? `getdate()` returns `datetime` data type – Squirrel May 15 '20 at 02: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`. – Zhorov May 15 '20 at 06:35
  • 1
    Looks good, just need to add time offset? – hoggar May 15 '20 at 10:12

1 Answers1

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