user2447136
user2447136

Reputation: 189

Date function for following month

What function can I use to get the date for the following month, in the format 201907?

The following code snippet returns 201907, but I need a function that will always return the next month

select 
    convert(varchar(6), DATEFROMPARTS(YEAR(GETDATE()), 7, 1), 112)

Upvotes: 1

Views: 57

Answers (1)

Chris Mack
Chris Mack

Reputation: 5208

You can use DATEADD:

SELECT CONVERT(varchar(6), DATEADD(MONTH, 1, GETDATE()), 112)

Upvotes: 4

Related Questions