this is my query
begin
select substring(intourpackagefromtodates,0,dbo.LastIndex(intourpackagefromtodates,'-')) as date1 from tourdetailsnew where vctourcode='bj-456' and intourday='2'
select substring(intourpackagefromtodates,dbo.LastIndex(intourpackagefromtodates,'-')+1,len(intourpackagefromtodates)-(dbo.LastIndex(intourpackagefromtodates,'-'))) as date2 from tourdetailsnew where vctourcode='bj-456' and intourday='2'
select datediff(d,date2,date1)+1 as days
end
error is
Msg 207, Level 16, State 1, Line 7
Invalid column name 'date2'.
Msg 207, Level 16, State 1, Line 7
Invalid column name 'date1'.
select substring(intourpackagefromtodates,0,dbo.LastIndex(intourpackagefromtodates,'-')) as date1 from tourdetailsnew where vctourcode='bj-456' and intourday='2'
this query returns
23/04/2010
select substring(intourpackagefromtodates,dbo.LastIndex(intourpackagefromtodates,'-')+1,len(intourpackagefromtodates)-(dbo.LastIndex(intourpackagefromtodates,'-'))) as date2 from tourdetailsnew where vctourcode='bj-456' and intourday='2'
this return
21/04/2010
if i avoid
select datediff(d,date2,date1)+1 as days
iam struck in section
Regards
K L BAIJU
Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator