Solved

Find current date and previous year date

Posted on 2015-01-05
3
123 Views
Last Modified: 2015-01-08
ASPxComboBox_currentYear are the values  below. If 2015 is selecteded, current_targetDate should be 1/5/2015 and
previous_targetDate should be 1/5/2014. If 2014 is selected current_targetDate should be 1/5/14 and previous_targetDate
should be 1/5/2013 and same pattern with other years. Not sure I am doing wrong here. in future, I am going to set ASPxComboBox_currentYear from db, instead of hard code it.
 <dx:ListEditItem Text="Select" Value="" Selected="true" />
                        <dx:ListEditItem Text="2015" Value="2015"/>
                        <dx:ListEditItem Text="2014" Value="2014"/>
                        <dx:ListEditItem Text="2013" Value="2013" />
                        <dx:ListEditItem Text="2012" Value="2012" />
                         <dx:ListEditItem Text="2011" Value="2011" />
                    </Items>
 </dx:ASPxComboBox>



  Dim current_targetDate As Date
  Dim previous_targetDate As Date


 Dim i As Integer = 0
        For i = 0 To numberOfYear
            If CInt(ASPxComboBox_currentYear.Value) = current_year - i Then
                current_targetDate = DateTime.Today.AddDays(i)
                previous_targetDate = DateTime.Today.AddYears(-1 - (1))
                Exit For

            End If
            i += 1
      
        Next

Open in new window

0
Comment
Question by:VBdotnet2005
  • 2
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 40532649
Why not just
current_targetDate = new-datetime(ASPxComboBox_currentYear.Value, datetime.today.month, datetime.today.day)
previous_targetDate = new-datetime(ASPxComboBox_currentYear.Value -1 , datetime.today.month, datetime.today.day)
0
 

Author Comment

by:VBdotnet2005
ID: 40532686
Thank you :)
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40532707
Glad I could help. :^)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

820 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