Solved

Return date as lastyear date

Posted on 2014-12-31
4
156 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
ID: 40525852
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 77

Expert Comment

by:arnold
ID: 40525857
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
ID: 40525858
Thank you Fernando
0
 
LVL 62

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

911 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

20 Experts available now in Live!

Get 1:1 Help Now