SQL server datetime column filter on certain date or range of dates
There is an example for today here
Get row where datetime column = today – SQL server noob
I am primarily interested in 2008 only. For today it looked like
SELECT (list of fields) FROM dbo.YourTable WHERE dateValue BETWEEN CAST(GETDATE() AS DATE) AND DATEADD(DAY, 1, CAST(GETDATE() AS DATE))
What literal value of date(s) or functions ( I need a format ) should I place there to make it work independent of local settings.
One Solution collect form web for “SQL server datetime column filter on certain date or range of dates”
Your query will work as it stands because it uses date/time datatypes only. That is, because you have no varchar involved then SET DATEFORMAT or SET LANGUAGE settings do not apply.
And because it’s SQL Server 2008, you can use the “date” type which has time part removed.
Or have I misunderstood?
You can use this format yyyymmdd because it is the “safe” format for SQL Server regardless of settings.
See may answer here please: sql server datetime