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
 General SQL Server Forums
 New to SQL Server Programming
 Querry Help!!!

Author  Topic 

sqlspider
Starting Member

16 Posts

Posted - 2005-08-25 : 10:17:21
Is there a way I can frame the querry for the following scenario??

column1
--------
item1
item2
item3
...
..


Querry: Select datediff(month,item1,item2) and next for item2 and item3...

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-25 : 10:26:39
Try this

Select 'Select DateDiff(D,'+cast(t1.column1 as varchar)+','+ cast(t2.column1 as varchar)+')'
from yourTable t1 inner join yourTable t2 on t1.column1>t2.colum1


Madhivanan

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

sqlspider
Starting Member

16 Posts

Posted - 2005-08-25 : 10:59:49
Hi Madhivanan
I am getting an syntax error converting datetime from charecter string...

I also do not wish to have two tables. Is there any way I could iterate the row values in the same column to get a datediff??

thank you for your input.

Vik
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-26 : 00:42:54
I think the query I suggested will work
Post the table structure and provide some sample data

Madhivanan

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

- Advertisement -