Taking month and year

Asked

Viewed 34 times

2

I have a variable containing it an expression that corresponds to a directory of folders.

I want the year and the month before:

"c: " + SUBSTRING( (dt_str, 50, 1252)GETDATE(), 1, 4 ) + " " + RIGHT("0" + (DT_STR, 2, 1252) MONTH( DATEADD("MONTH",-1,GETDATE()),2)

Sai: c: 2017 09

, but let’s imagine that it is January and the previous month is (12) and the year is also the previous. The way it is, every year I would force myself to intervene.

There is no way around this and put a relationship between the month and the year, so that it is always automatically?

1 answer

0

  • Hello @Tiago. Avoid putting only links in your reply. Pick up code snippets that can support your response.

  • @Joãomartins, better than code snippets, only official microsoft documents...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.