Donate SIGN UP

Concatenation of DATEPART functions

Avatar Image
TheUnderTow | 09:59 Tue 05th Sep 2006 | Technology
2 Answers
I am trying to concatenate DATEPART(day, Order_Date) from a given table with DATEPART(Month, GETDATE()) and DATEPART(Year, GETDATE()) but all the results I am getting so far have been 2041 which is of NO use whatsoever! Does anyone have an idea as to the code for this? It may well be ridiculously straightforward and I apologise for my ignorance if it is!
Gravatar

Answers

1 to 2 of 2rss feed

Best Answer

No best answer has yet been selected by TheUnderTow. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
As you are using the GETDATE() function I am assuming you are using SQL server, you can't concatenate if the results are not strings

SELECT CAST(DATEPART(d,[Order_Date]) AS nvarchar(2)) + CAST(DATEPART(m,GETDATE()) AS nvarchar(2)) + '/' + CAST(DATEPART(y,GETDATE()) AS nvarchar(4)) FROM yourtablename
Sorry the year part is yy not y

1 to 2 of 2rss feed

Do you know the answer?

Concatenation of DATEPART functions

Answer Question >>

Related Questions

Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.