If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: date between

Originally posted by catorene RE: hi, anybody know an easy way to select fields between two dates? I have tried dateadd like DATEADD(day, 28, myDate) but the result I want is from i.e 07.15 to 08.15. I have also tried something like CONVERT(varchar, myDate, 104) BETWEEN '07.15.2002' AND '08.15.2002'
anyone have another suggestion?

Q1 [Anybody know an (easy?) way to select fields between two dates?]
A1 It isn't really clear what you are asking about. A between syntax example?:

SELECT ord_date AS DatesBetween19930221And19940913
FROM pubs.dbo.sales
WHERE (ord_date Between CONVERT(DATETIME, '1993-02-21 00:00:00', 102) AND CONVERT(DATETIME, '1994-09-13 00:00:00', 102))
ORDER BY ord_date

You actually were on the right track - it is just that style 104 is the format dd.mm.yy not mm.dd.yy like in your between clause. So if you modified your dates in the between clause to be 15.07.2002 and 15.08.2002 you would be ok. Also, you could use style 101 but you would need slashes instead of periods - and your date 07/15/2002 and 08/15/2002 would work as well.