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 |
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2006-04-05 : 10:28:56
|
| I confused myself and I need some help.I have an Edate which could be any dateDECLARE @EDate smalldatetimeset @EDate='01/01/2005'--any datealso I have IDatesCount whic is just number.select IDatesCount from table1I need to write an if statement which will do this:if days count(edate plus IDatesCount) morethen IDatesCount print 'more'Else print 'less' |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-05 : 10:32:45
|
| Post some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2006-04-05 : 10:44:04
|
| If Edate='04/01/05' and IdateCount =30 it should print 'less'If Edate='01/01/05' and IdateCount =30 it should print 'more'If Edate='01/01/05' and IdateCount =60 it should print 'less'If Edate='02/01/05' and IdateCount =30 it should print 'less' |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-04-05 : 11:21:32
|
| [code]Declare @Edate varchar(10),@IdateCount IntSelect @Edate = '04/01/05', @IdateCount = 30-- if ur comparison is @IdateCount vs. # of days in the monthif datepart(dd,Dateadd(d,-1, dateadd(m,1, convert(datetime, @Edate) ))) <= @IdateCount Print 'Less'Else Print 'More'[/code]-- Which will not give the expected results for ur 3rd data / results set-- or if ur comparison is @IdateCount vs. something else let us know what it is-- Ur data doesn't reflect any relationship with the results u postedSrinika |
 |
|
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2006-04-05 : 11:33:16
|
| My edate can be in a future,present,past.I need to run a process every day for DatesCount . When it reach that DatesCount from edate then exit the process.Will this explanation helps you understand. |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-04-05 : 11:54:56
|
| Define DatesCount Tell, how u compare DatesCount (an integer) and edate (date)Srinika |
 |
|
|
|
|
|