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)
 problem with dates

Author  Topic 

khalik
Constraint Violating Yak Guru

443 Posts

Posted - 2002-04-26 : 02:17:09
by mistake i posted it in general sql so just a same one
if seen it avoid it

i have a small problem ... its a telecome poject
i charge subscription in advance and when a unit get disconnect in backdate in my next bill i have to refund...

below is the sample data

create table #bill (unit_id numeric,amt numeric,stdt datetime,endt datetime)
insert into #bill values(215,31,'2001-10-01','2001-12-31')
insert into #bill values(215,34,'2002-01-01','2002-03-31')
insert into #bill values(215,32,'2002-04-01','2002-06-30')
insert into #bill values(214,32,'2002-04-01','2002-06-30')

disconnect date is '2002-02-25'

now the problem is i need the rows which all i have to refund..
i.e

215 34 2002-01-01 2002-03-31
215 32 2002-04-01 2002-06-30

now do i get this.....
thanks in advance




======================================
Ask to your self before u ask someone

Peter Dutch
Posting Yak Master

127 Posts

Posted - 2002-04-26 : 02:23:23
What makes a unit 'in backdate'?

Why do you need the 2nd and 3rd entry in the demo data, and not the first?

Go to Top of Page

khalik
Constraint Violating Yak Guru

443 Posts

Posted - 2002-04-26 : 02:41:43


b'cos the unit got disconnect on '2002-02-25' so i should be refunding after '2002-02-25'
any thing before '2002-02-25' is use
so only after '2002-02-25' date

======================================
Ask to your self before u ask someone
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2002-04-26 : 07:01:10
This is my understanding of the question:
select *
from #bill
where convert(datetime, '2002-02-25') between stdt and endt

BUT it will not give you the required recordset.
I don't understand why row 3 is valid but row 4 is not.
They have the exact same dates.

Please clarify the meaning of "in backdate".
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-04-26 : 18:06:13
quote:
I don't understand why row 3 is valid but row 4 is not.
They have the exact same dates.



Just a WAG, but I notice that it has a different Unit_ID. Unit_ID was not mentioned in the original question anywhere, so we don't know for sure...

Go to Top of Page
   

- Advertisement -