Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Month count between two dates
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01084837
Message ID:
01084877
Vues:
9
This message has been marked as the solution to the initial question of the thread.
>>>Hi,
>>>
>>>
>>>In C#, how can I get the month count between two dates.
>>>
>>>Something like this
>>>
>>>iMonthCount = dDate1 - Date2 // Result in months
>>>
>>
>>DateTime objects in .NET have a Month property that you can use for this.
>>Something like this should help you get started:
>>
>>int iMonthCount = dDate1.Month - dDate2.Month;
>>
>>
>>Einar
>
>huuummm...
>but, if the year is not equal the result is not correct.

That is correct, but I figured that I would leave a little of the code for you :)
The DateTime object also has a Year property that you can calculate the difference in years and then yous multiply by 12.

Einar
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform