Solved

Return date as lastyear date

Posted on 2014-12-31
4
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 63

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 78

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 63

Expert Comment

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

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

710 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