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 2008 Forums
 Transact-SQL (2008)
 % Operator

Author  Topic 

dbthj
Posting Yak Master

143 Posts

Posted - 2011-12-02 : 10:16:47
In a post to SQLteam titled, "How to verify the date is saturday or sunday" One entry said to consider

select DATEDIFF(DAY, 0, GETDATE()) % 7 / 5

I have no idea what is being considered here, and, frankly, I don't much care. But what I mostly don't understand is what kind of an operator % is. What does it do? Is this some kind of bitwise doohicky?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-02 : 10:19:47
its called Modulo operator. it returns reminder of division as the result (in this case reminder obtained on total days value returned by datediff / 7)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -