简体   繁体   中英

Get the following Yearmonth

我将如何获得 202001

@year = 2019 and @month = 12

Where [yearmonth] = CONCAT(@Year, @Month) + 1
Where [yearmonth] = FORMAT(DATEADD(m, 1, DATEFROMPARTS(@year, @month, 1)), 'yyyyMM')

这是小提琴

Assuming these are numbers, you can use arithmetic:

where yearmonth = ((@year * 12 + @month + 1) / 12) * 100 +
                   (@year * 12 + @month + 1) % 12
                  )

If it is a string, you can convert.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM