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)
 Help needed regarding using datediff function

Author  Topic 

kranthi_victroy
Starting Member

5 Posts

Posted - 2007-08-24 : 11:48:21
Hi,
I have to check month of current date with all rows of month in the table XYZ. If there is any difference, we have to return error message.

I am using datediff function but I am getting error at 'MM'. DateDiff(MM,Select getDate(), Select date1() from xyz). can any body help
me in solving this issue.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2007-08-24 : 11:53:47
SELECT DATEDIFF(month,getdate(),date1)
FROM xys

Jim
Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2007-08-24 : 11:54:40
[code]SELECT DATEDIFF(MM, GETDATE(), Date1) FROM xyz[/code]

Mark
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2007-08-24 : 11:55:27
or probably
SELECT *
FROM xyz
WHERE DATEDIFF(month,getdate(),date1) >0
Go to Top of Page

kranthi_victroy
Starting Member

5 Posts

Posted - 2007-08-24 : 11:58:31
Thankyou
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-24 : 14:08:35
More caveats about DATEDIFF function
http://www.sqlteam.com/article/datediff-function-demystified



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -