Click here to Skip to main content
14,539,823 members

Vietnamese Lunar Calendar for .NET

Rate this:
4.08 (8 votes)
Please Sign up or sign in to vote.
4.08 (8 votes)
18 May 2012CPOL
Implementation of Âm lịch Việt Nam for Microsoft.NET


This is an implementation of Am lich VN ( in C# / .NET 2.0. It's useful to calculate the Vietnamese lunar date in a .NET application (and I hope this source code may be used as a build-in for the Microsoft .NET Framework).


This article uses the algorithm of author Ho Ngoc Duc ( to make a VietnameseCalendar class (it's similar to the ChineseLunarCalendar class - a build-in of Microsoft .NET 2.0).

Using the Code

You may use this class to convert a solar date (Gregorian calendar) to a Vietnamese lunar date and vice versa.

// From VN lunar date to solar date
DateTime d = new DateTime(2008, 9, 1, new VietnameseCalendar());
Console.WriteLine("Solar date of Vietnam New Year - Mau Ty = '{0}'", d);   
// From solar date to VN lunar date
VietnameseCalendar vCal = new VietnameseCalendar();
DateTime dt = new DateTime(2008, 9, 30);
vCal.FromDateTime(dt, out y, out m, out d);
Console.WriteLine("VN lunar date of 2008/9/30 = 'Nam {0} - {1}({1}) - Ngay {3} ({4})
 - Gio bat dau: {5} - Tiet {6}, Gio Hoang dao: {7}",
  VietnameseCalendar.GetMonthSpeechName(y, m),
  VietnameseCalendar.GetMonthName(y, m),
  d, VietnameseCalendar.GetDayName(dt),

* You can use this class to get VN lunar start hour of a day; or get Minor solar terms; Propitious hours in a day,... 

* A Vietnam lunar month can be 1 to 13 (because of leap-month) as a numeric. Example:
   VN Lunar year 1979 has leap-month: 6
   So this year has 13 months (from 1 to 13, as an int) like:
    [1], [2] ... [5], [6], [7 => 6(N)], [8 (=> 7)], [9] ... [13]
   So, if you convert 1979-9-17, you will received 1979/8/26 as output numbers, but string will be "26, Tháng Bảy, Năm Kỷ Mùi" (if you use the method: GetMonthSpeechName(y, m))

Points of Interest

This class has been tested by unit-testing (in the attached file). Here is that class diagram:



  • 16th October, 2008: Initial post


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


About the Author

Software Developer (Junior)
Vietnam Vietnam
No Biography provided

Comments and Discussions

QuestionThank you Pin
ban ghe cafe26-Apr-17 23:15
Memberban ghe cafe26-Apr-17 23:15 
QuestionBug Pin
phamthaihoa28-Feb-14 22:17
Memberphamthaihoa28-Feb-14 22:17 
QuestionThanks Pin
aspneter26-May-12 8:19
Memberaspneter26-May-12 8:19 
QuestionWrong date when you convert in a lunar leap year Pin
Nguyen Vu Thuy10-May-12 20:23
MemberNguyen Vu Thuy10-May-12 20:23 
AnswerRe: Wrong date when you convert in a lunar leap year Pin
nthachus11-May-12 6:34
Membernthachus11-May-12 6:34 
AnswerRe: Wrong date when you convert in a lunar leap year Pin
nthachus18-May-12 11:55
Membernthachus18-May-12 11:55 
AnswerRe: Wrong date when you convert in a lunar leap year Pin
wentou18-May-12 21:48
Memberwentou18-May-12 21:48 
GeneralError when convert to Lunar date Pin
iSoftVN8-Jun-09 17:24
MemberiSoftVN8-Jun-09 17:24 
GeneralRe: Error when convert to Lunar date Pin
nthachus18-May-12 12:08
Membernthachus18-May-12 12:08 
QuestionLeap Year 2009 Pin
ada260324827-Apr-09 0:32
Memberada260324827-Apr-09 0:32 
AnswerRe: Leap Year 2009 Pin
nthachus11-May-12 6:38
Membernthachus11-May-12 6:38 
AnswerRe: Leap Year 2009 Pin
nthachus18-May-12 12:03
Membernthachus18-May-12 12:03 
GeneralThanks Pin
phamthaihoa25-Apr-09 0:37
Memberphamthaihoa25-Apr-09 0:37 
GeneralThank you Pin
Hai M. Nguyen9-Feb-09 15:37
MemberHai M. Nguyen9-Feb-09 15:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 16 Oct 2008


14 bookmarked