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 |
|
amitranjan
Starting Member
45 Posts |
Posted - 2011-01-17 : 11:55:30
|
| Hi, My query is simple yet bit twisted for me. Actually I am working on registration module of an app, where the registration expires 31st March every year. The registration is valid from April 1 to March 31. So whenever a user is registered in between the date, I want his status to be expired if march 31 is crossed.Let me make more clear to you.Say I have registered my self in 15Nov2010, then on 31st March 2011, my subscription will get expired. I want to check it automatically as the years will go on. I need a query that will automatically query the created date with expiration date. I am already having a select query and i need to embed this condition and i want to check the creation date with current system date. If Current system date is not 31 march midnight 12, the status must be active else expired.amit Ranjan |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-01-17 : 12:20:49
|
| This will give March 31 of the current year, that you can the compare your registration date to. However, you can't use getdate() inside a function.select dateadd(month,datediff(month,0,getdate()) ,'18990331')JimEveryday I learn something that somebody else already knew |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-01-18 : 09:53:43
|
| <<you can't use getdate() inside a function.>>In versions from 2005, it is allowedMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|