views:

119

answers:

1

There is an example for today here

http://stackoverflow.com/questions/2583228/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.

+2  A: 

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?

Edit:

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

gbn
I shouldn't have included the example from other thread. Is it just BETWEEN '20100511' AND '20100513' in order to collect anything for May11-May12 inclusive ?
MicMit