Reputation: 17278
How can i change dateformat?Forexample:
2009-06-10 10:16:41.123
->2009-June2009-05-10 10:16:41.123
->2009-MayUpvotes: 0
Views: 1424
Reputation: 4639
Its a pain to do custom formats without writing your own function.
best i have is SELECT NewFormat = YEAR(GETDATE()) + '-' + DATENAME(month, GETDATE())
Upvotes: 0
Reputation: 294237
To interpret input use SET DATEFORMAT
To cast to character, see the CONVERT styles.
To format output, use whatever your client environment uses to format output, SQL itself has no output but TDS and display is left to the client.
Upvotes: 0
Reputation: 56934
You should not change the date-format in your database. You should just make sure that , when displaying the date, you correctly format the date, so that you display them in the format that you want.
How to do that, is related to the language you use in your program. You can also output the date directly in the format you want using the method of ck.
Upvotes: 2
Reputation: 46425
Try this:
select cast(datepart(year, mydatecolumn) as char(4)) + '-'
+ datename(month, mydatecolumn)
from mytable
Upvotes: 0