Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if a particular date is submited eg 7/6/1991

the out put should be displayed in a labe as follows 21years,3months,113days

is it possible
Posted
Comments
[no name] 13-Sep-12 10:31am    
Yes, it is possible.
Raje_ 13-Sep-12 10:42am    
Tit for tat, nice answer. (Is it possible:- yes, it is possible)
fjdiewornncalwe 13-Sep-12 14:38pm    
if( dateSubmitted == "7/6/1991" ) { outputdisplay = "21years,3months,113days"; }...
Try expanding your question...

C#
DateTime Date = new DateTime(2010,9,10);
           DateTime Date2 = DateTime.Now;

           TimeSpan Diff = Date2 - Date;
           int years = Diff.Days / 365;
           int Months = years / 12;
           double Days = Diff.Days % 365 ;
           Console.WriteLine("{0} Years - {1} Months - {2} days ",years,Months, Days);
           Console.ReadLine();
 
Share this answer
 
v2
Yes it's possible.
Try this out:
HTML:
C#
<asp:textbox id="txtDate" runat="server" xmlns:asp="#unknown" />
<cc1:calendarextender id="CalendarExtender1" runat="server" xmlns:cc1="#unknown">
        OnClientDateSelectionChanged="dateSelectionChanged" 
        TargetControlID="txtDate" PopupButtonID="imgCalendar">
</cc1:calendarextender>

Javascript:
JavaScript
<script type="text/javascript">
  function dateSelectionChanged(sender, args){
    var selectedDate = sender.get_selectedDate();
    /*Do your calculations here. Get the result and set the value to the textbox*/
    document.getElementById("txtDate").value = selectedDate; 
 }
</script>



--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900