February 10, 2003 at 12:00 am
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/sjones/y2kstrikesagain.asp
February 16, 2003 at 3:36 pm
Steve, you could simplify your WHERE clause with something like this:
WHERE m.entrydate >= CAST(CONVERT(char, CURRENT_TIMESTAMP, 112) AS datetime)
AND m.entrydate < CAST(CONVERT(char, CURRENT_TIMESTAMP, 112) AS datetime)+1
This is more efficient, if you have an index on entrydate column!
HTH,
Vyas
HTH,
Vyas
SQL Server MVP
http://vyaskn.tripod.com/
February 17, 2003 at 9:37 am
Thanks, you are right. My quick query was to just match the day month and year, which caused the bug. If I'd gone with yours, I'd never have had an issue.
course, wouldn't have had an article either.
Steve Jones
February 19, 2003 at 9:58 am
Steve, my WHERE clause would be even simpler, if you just want to see all the notes posted the same day you are running your query:
WHERE m.entrydate BETWEEN
CONVERT(datetime, CONVERT(char, GETDATE(), 101)) AND GETDATE()
This would get all notes submitted between midnight and "right now".
Hope that helps,
Julie Liles
February 19, 2003 at 11:38 am
Steve,
Great article but, part of it is missing.
Quote:
If I check the table, I see
Unquote
You see what????
-SQLBill
February 19, 2003 at 7:10 pm
Ahhh, I think you need your secret decoder ring, SQL Bill.
something appears to be missing. I'll have to check at home when I get back. Gone for 2 days. In the table I found the entry that was displayed was dated the previous year and there were no entries from the current date.
Steve Jones
February 17, 2004 at 2:42 am
Mmmm. Must admit only done this in testing, mind you I would be happy if this was the only mistake I made, you should see some of my big faux pas', Now I never use the DATEPART abbreviations. Not much help to you now I suppose.
I am intrigued though when I look at my old code (from years back) and think how poorly written it is or where 'bugs' could creep in (quick fix while no one is looking ).
I am a great believer in that I learn more from my mistakes than my successes.
Far away is close at hand in the images of elsewhere.
Anon.
February 17, 2004 at 3:52 pm
Intellisense = Yukon. We just need hang out a little longer 'til we can catch up with the rest of the development world.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply