sql-server

How do i convert English date to Nepali date


How do i convert English date 2017/11/11 to its Nepali date(date according to Nepali calendar) .I have searched lot of article but couldn't found any article based on that.Please help


Solution

  • Nepali Calendar is based on Bikram Sambat and is 56 years and 8 months ahead of A.D. The Bikram Sambat calendar was started in 57 B.C. by King Bikramaditya in India.

    there is an approximate difference of 57 years, 8 months and 16 days between these dates. To obtain BS date, you need to add 57 years, 8 months and 16 days to AD date. But the main problem is that there may be a difference of +/- 3 days

    I Assuming 56 years and 8 months

    SELECT GETDATE() AS 'English Date',
       DATEADD(MONTH,8,DATEADD(YEAR,56,GETDATE())) AS 'Nepali date'
    

    for more information about DATEADD

    visit http://sqlhints.com/2014/07/05/how-to-add-days-weeks-months-quarters-or-years-to-a-date-in-sql-server/