Solved

Find current date and previous year date

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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