SQL Date Range - Leap Year
i have query runs date range:
select *
frompaymentmethods p
left join showparsedemails o
on o.orderno = p.orderid
where orderid in (select orderno pinpoint.dbo.showparsedemails orderdate >= '2/1/12' , orderdate <= '2/29/12')
order orderdate
this query not return 2/29/12 dates unless put last date 3/1/2012. other months, pick orders on start or end date, not leap year.
any reason why this? how can fix it?
thanks in advance.
is leap-year dates affected here, or date? don't say, columns plain dates, or datetimes? if they're datetimes, 2012-02-29 01:23:45 (for example) might not considered <= 2012-02-29 (with implicit 00:00:00 time component), depending on how querying, not match filter.
btw, make sure you're not hardcoding dynamic values in sql: parameterise them. suspect code you've posted simplified example though, might doing this.
--
adam
More discussions in Database Access
adobe
Comments
Post a Comment