Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
2,334 Views
0 Comments

Fast Lane: Just download attached files, self explanatory.

Easter Sunday, kids asleep, now daddy gets to play. I decided (month ago) to port my code for calculating Easter Sunday to Hana,

for fun of it and to test CTE and UDFs on Hana .

It was not as easy as I thought it would be.  My Hana SPS09 rev93.

I had to abandon idea of using CTE's and connected to that my old MS SQL code.

It was said CTE's should  work, although not official yet, but I was not able to stumble upon syntax to make it work.

When I gave up, kids were asleep no more, so night shift was ahead.


I had my diskette with Clipper Summer'87 Easter calc code, but no floppy in laptop :smile:


So I googled and found nice simple algorithm, not elegant but now I did not care any more :smile:

http://aa.usno.navy.mil/faq/docs/easter.php


Logical place to do calculation in was scalar UDF.

Then I learned that it does not support SQL statements

http://scn.sap.com/community/developer-center/hana/blog/2013/07/01/scalar-user-defined-functions-in-...

Should I use procedure ? Honestly, I would rather not do it at all then use procedure for such a thing.

Finnaly I just made it work, it was to late to post it (not easter Sunday any more), so I postponed posting it and added function for Orthodox Easter calculation using Meeus Julian Algorithm

http://en.wikipedia.org/wiki/Computus

It can be written differently, optimized, part of the code merged, with more variables, or less…certanly better documented :smile: , but here it is as it is, code attached in files also.

Gregorian Catholic Easter Calculation


Gregorian Ortodox Easter Calculation


Good Friday

is then peace of cake

select ADD_DAYS(get_easter_for_year(2015), - 2) AS "GoodFriday" from dummy ;

Easter Monday

in Croatia and some other countries is non working day so:

select ADD_DAYS(get_easter_for_year(2015), 1) AS "EasterMonday" from dummy ;


I also learned that now if I select a code in SQL editor and execute that it worked (just like in MS SQL SMS ).

Before it was not and entire script got executed as I recall. I missed that. Great then.

I've also lerned that in Hana integer divisions do not work like in MS SQL, so

select 3/2 "myInt" from dummy;

is not 1  but 1.5

as opose to

select 3/2 "myInt"   in MS SQL

Taking care of that I had to use FLOOR or CAST as INT.

I picked CAST.

So there You go,  fun is over.

Any corrections are wellcomed.

Happy Easter !

Labels in this area