Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to properly parse Buddhist year in MongoDB?

$
0
0

I am working with DateTime data which are stored in the Buddhist year but I need to convert it to the Gregorian year.

Actually, there is a simple solution (code below).

{"$dateSubtract": {"startDate": {"$dateFromString": {"dateString": "$receive_date","format": "%d/%m/%Y %H:%M"            }        },"unit": "year","amount": 543    }}

It works most of the time but it throws an error if receive_date is 29/2/2567 because 2567 in the Gregorian year is not a leap year but it is in the Buddhist year.

Do you have any suggestions to resolve this issue?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>