Get result of a query, converting field DateHora to local time zone

1

I have a table in the sql server database that has the following DataHora field where

I have data included in this format:

 DataHora
 2015-04-20 17:43:04.000

This time is not in the format of our time zone.

I need to make a query that in the result shows me the result Converted to our time zone

I have the following query:

  select Serial, 
 Latitude,
 Longitude,
 DataHora as DataHora
 from [CheckPoint] where DataHora between SWITCHOFFSET (CONVERT(datetimeoffset, '2015-04-22 10:00'),'-03:00')and SWITCHOFFSET (CONVERT(datetimeoffset, '2015-04-22 11:00'),'-03:00')
 and serial='113394' order by DataHora

Would there be any easier way to get this converted data? in my query I am passing a certain date and is converting to the indicated spindle ie what I type The time is now -3. so I will not get concrete data from the time indicated.

Doubt: I need to get this formatted data to our timezone, because the dates that will be passed by parameters are in local time zone.

    
asked by anonymous 22.04.2015 / 15:52

1 answer

-1

See if this statement is helpful:

Command:

SELECT CONVERT(varchar(10),CAST('2015-04-20 17:43' AS datetime2),103)+' '+ CONVERT(varchar(8),CAST('2015-04-20 17:43' AS datetime2),114) AS 'data'

Result:

20/04/2015 17:43:00
    
10.09.2015 / 20:12