0

I have tried this one, but getting wrong output!

declare @createdon datetimeoffset
set @createdon = '2017-09-16 05:50:56.0000000 +05:30'

select 
    convert(datetime2, @createdon, 1)

select 
    convert(datetimeoffset, convert(datetime2, @createdon, 1))
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Guna
  • 1
  • 6

1 Answers1

0
select CONVERT(VARCHAR(20), @createdon, 120)
The beginner
  • 624
  • 4
  • 17
  • That @createdon varibale value is today's 11.20 am alone..but after converting it shows another time – Guna Sep 16 '17 at 07:06
  • Now i have used like this.. SELECT DATEADD ( MINUTE, (DATEPART(HOUR,CAST(RIGHT(@createdon,5) AS DATETIME)) * 60 + DATEPART(MINUTE,CAST(RIGHT(@createdon,5) AS DATETIME))), CAST(@createdon AS DATETIME) ) – Guna Sep 16 '17 at 08:08