I have a database table that has a date_time column. I created a view where I pull records from the table where the date_time value is in between two dates. For the sake of example, let's say the view is pulling all records between '2015-04-20' AND '2015-04-26'. When I check the min and max dates, however, the min date is 2015-04-19 17:01:49.000
CREATE VIEW [dbo].[testview]
AS
SELECT * FROM table WHERE
EventDateTime BETWEEN '2015-04-20' AND '2015-04-26'
ORDER BY EventDateTime ASC
I have records from January 1, 2014 to April 29, 2015 in this table. When I check the results, they look ok for the most part, except for some reason it keeps pulling a record with a 2015-04-19 17:01:49.000 timestamp. All other recoirds are within the filter. WHY?
The data points being inserted into the database are in Pacific time instead of UTC. No changes are being made, the data is just being generated with a PDT timestamp, and that data is being directly inserted into the database without manipulation.
SQL Server has no concept of a time zone and inherits the system time from Windows. The timezone of the server that this install of SQL Server is on is Central time. Is SQL Server internally converting the times based on it's own system time, i.e. since it's in Central time, it assumes that all data_points are in UTC and then converts to Central time? Instead of searching for date_times above 2015-04-20 00:00:00 is it searching for records where the date_time is above 2015-04-19 18:00:00? Yet if that were the case, the above timestamp still wouldn't work.
Can someone please explain what is happening?