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.
| Author |
Topic |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2007-01-11 : 02:27:21
|
| dob='2006-05-15'need to display in format given belowmay-2006 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-11 : 02:32:40
|
Once again we turn to Books Online, an excellent source of information, and find this solutiondeclare @dob datetimeselect @dob = '20060515'select datename(month, @dob) + '-' + datename(year, @dob) Peter LarssonHelsingborg, Sweden |
 |
|
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-01-11 : 10:57:15
|
| If you just want the first 3 characters of the month, simply do a LEFT substring to what Peter has provided:declare @dob datetimeselect @dob = '20060515'select LEFT(datename(month, @dob), 3) + '-' + datename(year, @dob)For other date formats, you may also refer to the following link:http://www.sql-server-helper.com/tips/date-formats.aspxSQL Server Helperhttp://www.sql-server-helper.com |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-11 : 15:05:59
|
| Orselect right(convert(varchar, getdate(), 106), 8)Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|