SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Calculating date differences
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Emile
Starting Member

South Africa
5 Posts

Posted - 03/20/2013 :  04:57:32  Show Profile  Reply with Quote
Hello?
In my arLogDet table I'm trying to calculate the next date from the next SeqNo so that i can find the difference between the ActionEndDate
and ActionDueDate, I calculate the ActionDueDate from when the action started adding how many days the action will take then to see if it was completed in the appropiate time i check the date with SeqNo + 1 to get the next action date so that i can see if the action was passed to the next user before the ActionDueDate, this sql select statement will populate a tempory table in a proc.The date I want to get the results for is in arLogDet,the others tables are so i can get my UserId, DaysperAction.Im really struggling to figure this out???

select (select Date from arLogDet where SeqNo = SeqNo+1) as ActionEndDate,
U.UserId,
A.DaysPerAction,
D.SeqNo,
D.Date,
D.DocId,
D.RequestId,
DateAdd(Day, A.DaysPerAction, D.Date) as ActionDueDate

from awUser U
join arLogDet D
on U.UserId = D.UserId
join arLogHdr H
on D.RequestId = H.RequestId
join arAction A
on H.ActionId = A.ActionId
where U.UserId = 159
and H.RequestId = 55

bandi
Flowing Fount of Yak Knowledge

India
2206 Posts

Posted - 03/20/2013 :  05:23:45  Show Profile  Reply with Quote
--May be this
select (select Date from arLogDet where SeqNo = D.SeqNo+1) as ActionEndDate,
U.UserId,
A.DaysPerAction,
D.SeqNo,
D.Date,
D.DocId,
D.RequestId,
DateAdd(Day, A.DaysPerAction, D.Date) as ActionDueDate

from awUser U
join arLogDet D
on U.UserId = D.UserId
join arLogHdr H
on D.RequestId = H.RequestId
join arAction A
on H.ActionId = A.ActionId
where U.UserId = 159
and H.RequestId = 55

If not, post the sample data of sample data of each table and also explain the logic what you want... show us the expected output for your sample data.. Hence you can get quick responses

--
Chandu
Go to Top of Page

Emile
Starting Member

South Africa
5 Posts

Posted - 03/20/2013 :  07:01:20  Show Profile  Reply with Quote
thank you very much, that helps alot with this step, gonna try apply it, will be back soon
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2206 Posts

Posted - 03/20/2013 :  08:53:29  Show Profile  Reply with Quote
quote:
Originally posted by Emile

thank you very much, that helps alot with this step, gonna try apply it, will be back soon

Got the result

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000