Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Return date as lastyear date

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
VBdotnet2005
Asked:
VBdotnet2005
  • 2
1 Solution
 
Fernando SotoCommented:
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
 
arnoldCommented:
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
 
VBdotnet2005Author Commented:
Thank you Fernando
0
 
Fernando SotoCommented:
Not a problem VBdotnet2005, glad I was able ti help.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now