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 2005 Forums
 Transact-SQL (2005)
 Help with date range.

Author  Topic 

NguyenL71
Posting Yak Master

228 Posts

Posted - 2010-01-19 : 18:44:40
I need a query to display the date like below. Thank you in advance.

9/1/07
10/1/07
11/1/07
12/1/07
1/1/08

12/1/09
1/1/10

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-19 : 23:09:45
Use CONVERT with the appropriate style if you are using datetime data type. But you really should do this type of formatting inside your application and not in T-SQL. Keep presentation issues to the presentation layer.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-19 : 23:46:29
or do you want to generate a lists of date for 1st of the month ?

select [Date] = dateadd(month, number, '2007-09-01')
from master..spt_values
where type = 'P'
and number <= datediff(month, '2007-09-01', '2010-01-01')



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-01-19 : 23:50:19
OR Do you want to be be more clear in you post...

i.e.

What's the data type of the column?

Can you post the DDL of the table?

Can you post dsample Data in the form of DML?

Can you tell us if you love Al Q....no, that's too far




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -