Solved

Find current date and previous year date

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

19 Experts available now in Live!

Get 1:1 Help Now