all groups > sql server programming > january 2008 >
You're in the

sql server programming

group:

Date Time?


Date Time? <KT>
7/14/2003 5:13:39 PM
sql server programming: What is the best way to use dates for comparison? I have the dates stored as
datetime types in SQL, and need to do a select via stored proc
mp_GetData (@instartDate as datetime, @inEndDate as datetime) as
select * from table where somedatefield between @instartDate and @inEndDate
'doesnt seem to work

Thanks KT

Re: Date Time? Andrew J. Kelly
7/14/2003 9:13:38 PM
"Doesn't seem to work" isn't a very descriptive clue as to what may be
wrong. Are you getting an error or just the wrong results? The way you
describe the select should be fine.

--

Andrew J. Kelly
SQL Server MVP


[quoted text, click to view]

RE: Date Time? Robert Durgin
1/18/2008 10:15:35 AM
Try adding 1 day to @EndDate. WHEN using between and puting in a date '1/18/2008' for example, sql server assumes '1/18/2008 12:00:00 AM' when performing a comparrision.

From http://www.developmentnow.com/g/113_2003_7_0_0_411955/Date-Time.htm

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button