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
 General SQL Server Forums
 New to SQL Server Programming
 Date Range

Author  Topic 

ramya2809
Starting Member

2 Posts

Posted - 2008-03-12 : 15:12:40
How to display start date and finish date together in the same column with a '-' in between?

2/24/2008 - 3/1/2008

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-03-12 : 15:22:26
declare @date datetime
select @date = '20080503'
select convert(varchar(10), @date, 101) + ' - ' + convert(varchar(10), @date, 101)

look up convert in BOL to get more formats besides 101

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-03-12 : 15:26:37
Assuming startDate and finishDate are varchar
SELECT startDate + ' - ' + finishDate FROM yourtable
or

SELECT CONVERT(varchar(10),startDate,101) + ' - ' + CONVERT(varchar(10),finishDate,101)
FROM yourtables , but that will return 02/24/2008 and 03/01/2008

Jim
Go to Top of Page

ramya2809
Starting Member

2 Posts

Posted - 2008-03-12 : 15:27:56
Thanks. It worked
Go to Top of Page
   

- Advertisement -