March 21, 2011 at 10:51 am
in where statment of the query, I am putting date 3/15/2011 and I don't get any data in return because:
data is 3/15/2011 11:42:00 AM.
How can I change field to get 3/15/2011
Thank you
0
March 21, 2011 at 11:11 am
select *
from MyTable
where MyDateColumn >= '3/15/11' and MyDateColumn < '3/16/11';
That's the basic idea.
If the date is a parameter or variable, you can use DateAdd to add 1 day to it and use that as the end-date.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 21, 2011 at 11:16 am
Thank you,but this is not what I am looking for:
I need to convert that field at the end = to 3/15/2011
datepart I thought,but can't figure out correct syntax
March 21, 2011 at 11:18 am
SELECT DATEADD(DAY, DATEDIFF(day, 0, GETDATE()), 0)
Just put your date column in there where it has getdate.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 21, 2011 at 11:23 am
Thank you this what I was looking for
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply