VBdotnet2005
asked on
Find current date and previous year date
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.
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help. :^)
ASKER