1
I have a table in the sql server database that has the following Datahora field where
I have data included in this following 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 show 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 these converted data ? in my query I am passing a certain date and is converting to the indicated zone ie what I type The time will be -3. then I won’t get concrete data of the given time.
Doubt: I need to get this formatted data to our time zone,
Are you only using SQL or are you using another language to construct the parameters?
– ramaral
Cara c#! I am showing only the query,but I have a method in my application where I send by parameter to Datahora
– Hans Miller
@Hansmiller has already found the solution?
– Marconi
What’s wrong with using the
SWITCHOFFSET
?– Maicon Carraro