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)
 How to display week format as monthno/day

Author  Topic 

learntsql

524 Posts

Posted - 2014-04-02 : 08:29:51
Hi All,

I have to display Week date for each month like monthno/day
for example, for April the starting week value should be as 04/01 (Tuesday) and next week values as
04/06 (Sunday)
04/13
04/20
04/27

and in may it should display startin week value as 05/01 (Thursday)
and
05/04
05/11 and so on...

Can some one please guide me how to get this format using SQL server 2008 R2 version.

Thanks a lot in advance.


djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2014-04-02 : 08:48:24
First you should uses a front end to format.

SELECT CONVERT(VARCHAR(5),GETDATE(),1)


djj
Go to Top of Page

sqlsaga
Yak Posting Veteran

93 Posts

Posted - 2014-04-02 : 17:50:28
I believe having a calendar table would be very useful for your scenario. Read an article I wrote on how to create the calendar table between desired dates @ http://sqlsaga.com/sql-server/script-to-populate-date-dimension/


Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.
Go to Top of Page
   

- Advertisement -