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 |
|
mmfarmani
Starting Member
22 Posts |
Posted - 2007-07-12 : 13:01:51
|
| Hello, I need to select records in the database which 15 days have been passed from their creation date... Means they are older than 15 days! It sounds easy but I have problem converting the date to calculate days…Thanks |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-12 : 13:04:26
|
| where yourDateColumn < dateadd(d, -15, getdate())_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-07-12 : 13:05:39
|
| where crdate < convert(varchar(8),getdate() - 15,112)where datediff(dd,crdate,getdate()) > 15==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-13 : 00:14:57
|
quote: Originally posted by spirit1 where yourDateColumn < dateadd(d, -15, getdate())_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp
I think you need to omit Time as well where yourDateColumn dateadd(d, -15, datediff(day,0,getdate()))MadhivananFailing to plan is Planning to fail |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-13 : 03:51:28
|
i'm leaving that as an excercise to the user _______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-13 : 08:18:55
|
quote: Originally posted by spirit1 i'm leaving that as an excercise to the user _______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp
Well said MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|