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)
 Please explain Code

Author  Topic 

OON
Starting Member

22 Posts

Posted - 2010-09-16 : 09:28:13
Can anyone please help me understand exactly what this piece if code is doing in lane man terms.

Thank you!!!
-----------------------------
CASE WHEN month(getdate()) > DATEPART(mm,dateadd(mm,0,DT.FullDate ))
then DT.MonthYearNameShort
ELSE CONVERT(VARCHAR(5),DATEADD(wk, DATEDIFF(wk,0,DT.FullDate ), 5),10) end as MONTHWEEK
------------------------------

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-09-16 : 09:41:17
Checks if the current month is greater than FullDates month, if so it uses another column to display else it gives you the month and Saturday end of week date.

But then you could have found that out by running the code.
Go to Top of Page

OON
Starting Member

22 Posts

Posted - 2010-09-16 : 09:45:01
Thank you for your response. I could have ran it but i didn't understand why it was structured that way. especially the last line.

Thanks you again!
Go to Top of Page
   

- Advertisement -