Resources » Code Snippets » Date & Time

To get the previous Month


Posted Date: 22-Oct-2008  Last Updated:   Category: Date & Time    
Author: Member Level: Silver    Points: 4



C# Code :

DateTime LastMonthDate=DateTime.Now.AddMonths(-1);
Response.Write(LastMonthDate.ToString("MM/dd/yyyy"));

VB.net Code:

DateTime.Now.AddMonths(-1).ToString("MM/dd/yyyy")

Result
if the current date is 10/22/2008 , then the output of the above code is 09/22/2008


Did you like this resource? Share it with your friends and show your love!

Responses to "To get the previous Month"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Ashutosh Jha
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India