Select the Hebrew equivalent of SQL Server DateTime columns

747 Views Asked by At

If I have a table of Gregorian birth dates stored in a DateTime column, how can I, given today's Hebrew date, determine if someone has a Hebrew birthday today?

I need to somehow select the equivalent Hebrew month and day of the Gregorian date stored in the table.

Unfortunately

where month(BirthDate) = x and day(BirthDate) = y

returns the Gregorian values and not the Hebrew values.

I need month(BirthDate) to return the Hebrew value

Is there a way to do this?

1

There are 1 best solutions below

3
Leon Yue On

According my experience, there isn't any functions support convert Gregorian Datetime to Hebrew date directly in Azure SQL database or SQL server.

Any suggestions, you can learn from Gregorian calendar and Hebrew calendar, try to encode the convert script or function by yourself.

The simplest way is that, since you have given the Hebrew date, you can convert it to Gregorian Date with so many tools from the internet, such as: Convert from Hebrew to Gregorian date. enter image description here

Then you can get the value of x(month) and y(day).

Hope this helps.