Home is there a better way of concatenating date type
Reply: 0

is there a better way of concatenating date type

user464
1#
user464 Published in July 17, 2018, 7:21 pm

I have Date Type colum with data looking like this:

2011-07-01 00:00:00.000

And i want to recive from that something like

2011-7-1

there is my way, but probably could be done better

SELECT CAST(YEAR(ModifiedDate) AS varchar(15)) + '-' + CAST(MONTH(ModifiedDate) AS varchar(15)) + '-' + CAST(DAY(ModifiedDate) AS varchar(15))
FROM Sales.SalesOrderDetail
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.334304 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO