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 2005 Forums
 Transact-SQL (2005)
 using datediff to return Y or N

Author  Topic 

magikminox
Starting Member

27 Posts

Posted - 2008-06-12 : 04:47:51
Hi GUYS

I am trying to use the datediff function to return a Y if difference is greater than 0 and a N if difference is less than or equal to 0

select if datediff(dd,maturity_date,log_changed) > 0 'Y','N')

and i am getting a syntax error.Can someone show me where i am getting it wrong.

In god we trust,everything else we test.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-12 : 04:50:06
select case when datediff(dd,maturity_date,log_changed) > 0 then 'Y' else 'N' end
Go to Top of Page

magikminox
Starting Member

27 Posts

Posted - 2008-06-12 : 04:59:39
you have been of great help.thanks and God Bless

In god we trust,everything else we test.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-12 : 05:01:18
quote:
Originally posted by magikminox

you have been of great help.thanks and God Bless

In god we trust,everything else we test.


you're welcome
Go to Top of Page
   

- Advertisement -