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 2000 Forums
 Transact-SQL (2000)
 List of dates(mm/yyyy) . Time period.

Author  Topic 

Stas
Starting Member

1 Post

Posted - 2006-08-10 : 21:04:27
How to get a list of dates in ‘mm/yyyy’ format for particular period of time.
In example:
DATENAME(DATEPART(MM, mStartDate)) + "/" + DATENAME(DATEPART(YYYY, mStartDate)) to GETDATE() where mStartDate will be 01/02/2005
MSSQL 2005
Thank you

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-10 : 21:31:05
You can use the function in the link below to get a list of dates in many different formats for any range of dates you chose.

select
DATE,
DATE_FORMAT_MM_DD_YYYY,
MM_YYYY =
left(DATE_FORMAT_MM_DD_YYYY,2)+
right(DATE_FORMAT_MM_DD_YYYY,5)
from
dbo.F_TABLE_DATE('20060101','20061231')
order by
DATE

Date Table Function F_TABLE_DATE
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519




CODO ERGO SUM
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-11 : 13:01:04
Also,http://weblogs.sqlteam.com/derrickl/archive/2005/01/08/3959.aspx

If you use front end application, use format function there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -