Solved

Return date as lastyear date

Posted on 2014-12-31
4
154 Views
Last Modified: 2014-12-31
How can I get last year from today?

This returns = 12/31/204. I also want it to return 12/31/2013.
 Dim current_targetDate As Date = Today
 result = 12/31/2014

 Dim previous_targetDate As Date = Today  ?
 result = 12/31/2013
0
Comment
Question by:VBdotnet2005
  • 2
4 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
This should give you what you need.

Dim current_targetDate As DateTime = DateTime.Today
Dim previous_targetDate As DateTime = DateTime.Today.AddYears(-1) 

Open in new window

0
 
LVL 76

Expert Comment

by:arnold
Comment Utility
you need to clarify whether you want the date on the last Wednesday in December 2013, or do you want the Day on which 12/31/2013 fell.  Those are not the same.

12/31/2013 was a Tuesday .
Today in 2013 was 12/25/2013

If you only care about the date, there are date math function where you can use date and subtract a year.
0
 

Author Closing Comment

by:VBdotnet2005
Comment Utility
Thank you Fernando
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Not a problem VBdotnet2005, glad I was able ti help.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now