.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Algorithm for Computing Age in Years, Months and Days?

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :.NET Framework
I am generating a crystal report.net that compute age of a person through formula. of course, there is the birthdate and current date. I am familiar with the datediff function but I want to compute is like: "18 Years, 2 Months and fifteen days old." it should include the leap year. Any Algorithm that I can apply to crystal report formula? Your help is very appreciated.

View Complete Post

More Related Resource Links


How to calculate childs age,but when i enter childs age as '03/27/2007' it returns 3 years where as actual age is 2 yr 11 months

Trustworthy Computing: Lessons Learned from Five Years of Building More Secure Software


Five years ago, Bill Gates issued a directive to enhance security across the board. Since then, many valuable lessons have been learned about building more secure software.

Michael Howard

MSDN Magazine November 2007

function or query to return continuous span of months $ years as rows in query



I am using SS2008.

There are many situations in which I need to return a table where the rows are EVERY calendar month between two dates, not just the months where there is data present.

Is there a function that would take a beginning and end date mmddyyyy which would do this?

For example if I wanted 1/2004 through 8/2010?




and so on to





Thanks in advance,




Get number of months from number of days



I have 2 dates (in the form MM/DD/yyyy) representing the start date of the employee and the end date of the fiscal year:

the employee started working on 12/15/2010 and the fiscal year ends on 08/31/2011

I want to calculate the number of months that the employee worked between those 2 dates

in reality this employee will have been working until 08/31/2011 for 8.5 months

datediff function returns 8

how to calculate exact number of months in sql?

thank you in advance

Calculating yrs, months, days, hours, mins, seconds between two dates. SQL


I'm trying to calculate the yrs, months, days, hours, mins, seconds between two dates with sql server or c# (ive just used sql more). 

I have some code below that I started, but I get some negative values for months, values over 31 for months, and there very well could be more issues. Honestly my math is not the greatest and Im just not sure how to fix it. I want the user to be able to enter their birthday and for it to calculate the yrs, months, days, hours, mins, and seconds they have been alive.

Any help would be great 


((DATEDIFF(MONTH,'10/16/1995',GETDATE()))-(DATEDIFF(YEAR,'10/16/1995',GETDATE())*12)) AS 'Months',
(DATEDIFF(DAY,'10/16/1995',GETDATE()))-(DATEDIFF(MONTH,'10/16/1995',GETDATE())*30) AS 'Days', 
(DATEDIFF(HOUR,'10/16/1995',GETDATE()))-(DATEDIFF(DAY,'10/16/1995',GETDATE())*24) AS 'Hours',
(DATEDIFF(MINUTE,'10/16/1995',GETDATE()))-(DATEDIFF(HOUR,'10/16/1995',GETDATE())*60) AS 'Minutes',
(DATEDIFF(SECOND,'10/16/1995',GETDATE()))-(DATEDIFF(MINUTE,'10/16/1995',GETDATE())*60) AS 'Seconds'

Months and Years between given two dates.


Hello All,

I have one query.

User will input two dates and I want to print months between those two dates.


  1. Suppose user enters From Date : 1-Apr-2010 and To Date : 15-Oct-2010


So my out put should be like









Please reply me sql query for that one as it is needed on urgent bases.

Events don't show up in a specific month and in last days of months whose calendar view include day



I actually faced a strange problem which is that when I add events in september 2011, they don't show up in the calendar view and the view remains empty but they appear in the all events view but events in other months appear.

Another strange thing is that I was adding events in July 2011. In the calendar view of July 2011, the first 6 days of August appear but this isn't the problem but the problem is that when I add about 3 events in 31 July then about another three from 31 July to 4 August and then about 2 events from 1 to 4 August, the events are collapsed and the 3 more items appear but when I click the link, I don’t see the events that were just on 31 July and I tried this too in the end of March so it seems that the months whose calendar view includes some days from the next month have a problem.

And finally when I change the month to be october 2010, I get error page with the text:

An unexpected erro has occured.

web parts maintenance page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator.

and I checked in more than one calendar and in more than one site and it's the same, So I'm asking if any one faced something like th

Tab container rendered with visibility:hidden - This was reported over three years ago.



Here is (more) code that demonstrates the issue.  If the control in the host page is removed the tab control renders correctly.  Otherwise it is rendered with the visibility attrubute set to hidden as reported in the above link.  Is this broken or am I doing something wrong?



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="S2.aspx.cs" Inherits="S2" %>
<%@ Register Src="~/SelectorPatternControl.ascx" TagName="TestControl" TagPrefix="sam" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
        <cc1:ToolkitScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></cc1:ToolkitScriptManager>

Cloud Computing: Windows Azure Platform for Enterprises


Learn all about Microsoft's Windows Azure platform at the architectural level and how it addresses enterprise cloud computing concerns including economics, security, storage and more. Included are an Azure pricing table and a sample cost calculator.

Hanu Kommalapati

MSDN Magazine February 2010

Cloud Computing: Patterns For High Availability, Scalability, And Computing Power With Windows Azure


Here we examine the typical cloud platform architecture and some common architectural patterns, along with their implementation on the Windows Azure offering from Microsoft.

Joshy Joseph

MSDN Magazine May 2009

Cloud Computing: Building Distributed Applications With .NET Services


We show you how .NET Services within the Azure Services Platform makes it easy to bring workflow apps to the cloud.

Aaron Skonnard

MSDN Magazine April 2009

Sustainable Computing: Imagine Cup 2008: Competing for Change


For the 2008 Imagine Cup, students have been challenged to use technology to enable a sustainable environment. Finalists in the U.S. competition recently presented their solutions in Los Angeles, and MSDN Magazine was there to see the innovative ideas participants have come up with.

Mitch Irsfeld

MSDN Magazine April 2008

Editor's Note: 20 Years and Still Going Strong!


Microsoft Systems Journal (MSJ) was founded in 1986. At the time, no other publication focused specifically on the needs of programmers who were using Microsoft tools and technologies. Two issues were produced in the first year, each with five articles.

Joshua Trupin

MSDN Magazine April 2005

C# In-Depth: Harness the Features of C# to Power Your Scientific Computing Projects


The C# language has been used quite successfully in many kinds of projects, including Web, database, GUI, and more. One of the last frontiers for the application of C# code may well be scientific computing. But can C# measure up to the likes of FORTRAN and C++ for scientific and mathematical projects?In this article, the author answers that question by looking at the .NET common language runtime to determine how the JIT compiler, Microsoft intermediate language, and the garbage collector affect performance. He also considers C# data types, including arrays and matrices, along with other language features that play an important role in scientific computing applications.

Fahad Gilani

MSDN Magazine March 2004

Editor's Note: The Future: A Few Days Away


The past year has been full of uncertainty and change. A year ago, everything seemed to be falling into place. Windows XP was nearing final release. An RC version of the Microsoft . NET Framework was whetting our appetites for the final February release.

MSDN Magazine November 2002

SENS: System Event Notification Services and WMI Enable Flexible, Efficient Mobile Network Computing


Networked applications must deal with a host of connection problems ranging from timeouts to congestion to unavailability. If these applications can check the current connection status and, when disconnected, cache transmissions, they become more efficient. Fortunately, both the System Event Notification System (SENS) and Windows Management Instrumentation (WMI) can send notifications to keep applications informed of network status. In this article, the author explains the use of several SENS interfaces, including ISensNetwork and ISensLogon, which trigger events for connects/disconnects and logons/logoffs, respectively. The author then shows how you can subscribe to each of these events, and follows with a discussion of when you might use WMI events instead.

Aspi Havewala

MSDN Magazine August 2002

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend