Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Previous Month Name

Author  Topic 

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2006-07-20 : 14:36:37
Hello All -

I need to pull the month name of the previous month, this is being used on a activex step on my dts package, "TodaysDate" is a global variable on the MM/DD/YYYY format.
Running the code below I get "JUL" as a result, what do I need to change so I get "JUN" as a result ?

Thanks in advance!

theprevmonth = UCase(MonthName(Month(dtsglobalvariables("TodaysDate")), True))


---

Thanks!
Igor.

MichaelP
Jedi Yak

2489 Posts

Posted - 2006-07-20 : 14:40:11
I'm going to take a stab at this.

Try this

theprevmonth = UCase(MonthName(Month(DateAdd(m, -1, dtsglobalvariables("TodaysDate"))), True))


EDIT: I think the m for month needs to be in quotes

theprevmonth = UCase(MonthName(Month(DateAdd("m", -1, dtsglobalvariables("TodaysDate"))), True))



Michael

<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>

Opinions expressed in this post are not necessarily those of TeleVox Software, inc. All information is provided "AS IS" with no warranties and confers no rights.
Go to Top of Page

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2006-07-20 : 14:55:18
Yep, it works with the quotes, thanks a lot!


---

Thanks!
Igor.
Go to Top of Page
   

- Advertisement -