Solved

Find current date and previous year date

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 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