Solved

Find current date and previous year date

Posted on 2015-01-05
3
117 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

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

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

15 Experts available now in Live!

Get 1:1 Help Now