Trying to build a date:
CAST('9/1/' + YEAR(GETDATE()) AS Datetime) AS test2
But does it not work?
Would you like to get something like "9/1/2010"?
you cannot concatenate string '9/1'with number: YEAR(GETDATE())so try the following:
'9/1'
YEAR(GETDATE())
select CAST ('9/1 /' + CONVERT (varchar (4), YEAR (GETDATE ())) AS Datetime) AS test2
SELECT CAST( '9/1/' + CAST( YEAR(GETDATE()) AS VARCHAR ) AS Datetime) AS test2
You need to pass YEAR (integer) to VARCHAR before you can add it.
try the following:
Select DateAdd(month, dateDiff(month, 0, getdate()) + 9 - MONTH(getdate()), 0)
You can use the string format YYYYMMDD.
Source: https://habr.com/ru/post/1731090/More articles:Parsing cookie headers in J2ME / BlackBerry apps - javawhat order when choosing data from a database? - sqlУменьшение базы данных на Android - androidWhat is the best way to create a stream in C ++ when passing a class and index? - c ++How do I create a signature for a billing request in the Amazon FPS Marketplace? - signatureБиблиотека с плавающей запятой для встроенного приложения - cOpenId - return returnTo url with POST instead of GET - openidHow to create an executable application for Excel macro? - c #SSL SSL client authentication in Adobe AIR - flashSQL NOT IN Clause - sqlAll Articles