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
 What does 'Month(4)' mean?

Author  Topic 

foresters.bisc
Starting Member

5 Posts

Posted - 2012-03-03 : 11:54:28
We found the following piece of SQL and don't know what the 'month(4)' portion of it is supposed to do. Any idea what this whole command does? Thx.

CAST(((Time_End.As_Of_Date - Certificate.ISSUE_DATE) month(4)) AS DECIMAL(18,6))

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-03 : 12:02:46
There is a syntax error in the code segment you have posted; regardless, in T-SQL the MONTH function returns the numeric month number of a given date. So MONTH(4) is equivalent to MONTH(CAST(4 AS DATETIME)). That is Jan 5, 1900. So you would get a result of 1 for the month.

http://msdn.microsoft.com/en-us/library/ms187813.aspx
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-03-03 : 12:11:50
It isn't a valid T-SQL syntax.
Which RDBMS are you using?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

foresters.bisc
Starting Member

5 Posts

Posted - 2012-03-05 : 12:57:25
Thanks for confirming that this SQL looks 'odd' at best. Will have to contact the User who submitted this inquiry and find out history and purpose of this SQL. And thanks for the lesson on 'Month(n)' systax
Go to Top of Page
   

- Advertisement -