?
Solved

Previous Month Function

Posted on 2005-05-02
5
Medium Priority
?
261 Views
Last Modified: 2010-04-23
I want to include in my program a function that will give me the previous month in the folowing format "MMM" or "APR".
I want to use this to include in a file name ex.   APR EOM - Outage Report.pdf

Is there a function in VB.net that will do this or is there a way to minus one from mydate(Now, "MMM") to do this??
0
Comment
Question by:mikevere
  • 2
  • 2
5 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 13910756
   Dim lastMonth As String = DateTime.Now.AddMonths(-1).ToString("MMM")

Bob
0
 
LVL 7

Expert Comment

by:Joe_Griffith
ID: 13910757
Format(Now.AddMonths(-1), "MMM")
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 13910771
You can use DatePart(DateInterval.Month, DateAdd(DateInterval.Month, -1, myDate)) to get the integer representing the previous month.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13910777
Dog pile :))

Bob
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 13910801
Yeah... it's a shame the date/time stamp doesn't show seconds ;)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question