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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Help with query

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 date
DECLARE @EDate smalldatetime
set @EDate='01/01/2005'--any date
also I have IDatesCount whic is just number.
select IDatesCount from table1

I need to write an if statement which will do this:
if days count(edate plus IDatesCount) more
then 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 want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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'
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-05 : 11:21:32
[code]
Declare @Edate varchar(10),@IdateCount Int
Select @Edate = '04/01/05', @IdateCount = 30

-- if ur comparison is @IdateCount vs. # of days in the month
if 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 posted


Srinika
Go to Top of Page

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.
Go to Top of Page

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
Go to Top of Page
   

- Advertisement -