I need to have a sql function which takes a valid SQL Server date an returns the moon-phase for that date. I found a function, but unfortunaley it is in pl-sql which I have no understanding of, I can convert the code as is, but I have no idea how to get the julian date in SQL Server.
This is the skeleton function I want to use
IF OBJECT_ID (N'dbo.fn_phaseOfMoon', N'FN') IS NOT NULL
DROP FUNCTION dbo.fn_phaseOfMoon;
GO
CREATE FUNCTION dbo.fn_phaseOfMoon (@DATE datetime)
RETURNS VARCHAR(30) AS
BEGIN
RETURN 'NA';
END
GO
The pl-sql code is located here, can someone please point me in the right direction, or help converting the code?
This is Java code that I’ve changed into MSSQL. See if does the trick for you.
I don’t know much about these stuff, so you have to check if the answer’s is correct
Source of Java code : http://www.voidware.com/moon_phase.htm