Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2007-07-20 : 01:07:59
|
| i remember seeing an article here on dates and sql but I can't find it - if someone can point me to it i would appreciate it.i have a datetime field called mydatehow do I select all records where mydate=today (without looking at the time) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-20 : 01:12:44
|
| where mydate=dateadd(day,datediff(day,0,getdate()),0)MadhivananFailing to plan is Planning to fail |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2007-07-20 : 01:18:39
|
| that's not correct - it returns no records and there are definitely records dated today (but records have a date and time) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-20 : 02:00:50
|
| Try a little harder please... (NOT Madhi)where mydate>=dateadd(day,datediff(day,0,getdate()),0)Peter LarssonHelsingborg, SwedenEDIT: Clarification of who to pay more effort |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-20 : 02:06:18
|
quote: Originally posted by Peso Try a little harder please...where mydate>=dateadd(day,datediff(day,0,getdate()),0)Peter LarssonHelsingborg, Sweden
Thanks MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-20 : 02:08:10
|
quote: Originally posted by esthera i remember seeing an article here on dates and sql but I can't find it - if someone can point me to it i would appreciate it.i have a datetime field called mydatehow do I select all records where mydate=today (without looking at the time)
Refer this articlewww.sql-server-performance.com/fk_datetime.aspMadhivananFailing to plan is Planning to fail |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2007-07-20 : 02:14:34
|
| thanks |
 |
|
|
|
|
|
|
|