Go4Expert (http://www.go4expert.com/)
-   ASP.NET (http://www.go4expert.com/forums/asp-net/)
-   -   Difference between dates (http://www.go4expert.com/forums/difference-between-dates-t28344/)

vidyadeb 8May2012 16:31

Difference between dates
1 Attachment(s)
Please advice my two get diffrence of two dates .Please also check attach. Please suggest this also or can send total different way doing it .

shabbir 8May2012 16:43

Re: Difference between dates
You are expecting too much by attaching your issue. You want someone to download solve and then give back to you where as you have not taken the pain to explain the issue inline.

bzforum 28May2012 22:06

Re: Difference between dates
I took the pain to open the doc and see what the OP needed...

He needs to get a Difference between 2 dates...a Start Date and the End Date but he wants to count it as months..

that means if the user has selected 01 June 2012 to 01 Aug 2012 the result should be 2 Months..

And here is the solution for it in VB.NET..

PHP Code:

        Dim startDate As DateTime DateTime.Now
        Dim endDate 
As DateTime DateTime.Now.AddMonths(20)

Dim totmonths As Integer DateDiff(DateInterval.MonthstartDateendDate)


and C#

For this you have to Reference to System.Data.Linq
PHP Code:

        DateTime startDt DateTime.Now;
DateTime endDt DateTime.Now.AddMonths(20);
int tot System.Data.Linq.SqlClient.SqlMethods.DateDiffMonth(startDtendDt);

I hope this has solved your querry...and next time be nice to post the description of the problem in the post..

All times are GMT +5.5. The time now is 00:45.