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 |
|
pssumesh2003
Starting Member
35 Posts |
Posted - 2009-12-18 : 06:49:46
|
| Hii have A table Account likeId Accno CreatedDate1 1005 26/10/09 11:32:182 1006 27 /11/09 12:11:23etcand Tran tableTId AID Amount TDate101 1 500 26/12/09 9:12:58102 2 1000 27 /12/09 7:11:23when i want select TId using query to check each account has a date to remit amount same day each month to 5 days extra.i use following queryselect TId,Amount from Tran T inner join Account A on A.Id =T.TIdwhere T.TDate between dateadd(m,datediff(month,A.createdDate,getdate()),A.createdDt)anddateadd(dd,5,dateadd(m,datediff(month,A.createdDate,getdate()),A.createdDt))when executing this i cant any rowmy desired output isall rows having remitence between the date of remitence & 5 day fter that |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2009-12-18 : 08:45:33
|
| So do Accounts only have 5 days from the day in Table A, or a Month and 5 Days?If its 5 days you want -Between A.CreatedDate AND DateAdd(d,5,A.CreatedDate)If it's a month and 5 days you want - Between A.CreatedDate AND DateAdd(d,5,DateAdd(m,1,A.CreatedDate)) |
 |
|
|
|
|
|
|
|