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 |
jafrywilson
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-10-22 : 09:01:02
|
Hi all.. Once again here for your kindly help...one user will be allowed only 30 days in the application..In the last 7 days mails will send him..If the user modified his account then another 30 days will be granted.It is stored in modified date column...I am having a table like this id.....created_date.....Modified_date1........28-9-2010...... NULL2........19-9-2010.......10-10-20103........25-9-2010...... NULL4........22-8-2010......26-9-2010Now my need is find the users who are in the last 7 days of their activation days..Including the modified date..30 days are calculated using the created_date column if modified column is null[bold]OUTPUT[/bold]id134 |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-22 : 10:22:04
|
TryI am assuming that both Created_date and Modified_date datatype is datetime.If you are using varchar then let us know.Select id, Datediff(dd,isnull(Modified_date,Created_date),Getdate()) <= 30 from yourtable |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-22 : 10:42:38
|
This?select id from tablewhere datediff(d,getdate(),dateadd(d,30,isnull(modified_date,created_date))) <=7 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|