A couple of ways you could do this.
MOD(INT((B2-DATE(2000;1;6))/27,3);4)+1
is the first result of a formula on stack overflow.
Date here is based on Jan 6, 2000
You can also have a small script to print out the current phase of the moon into a textfile that gets loaded in and checked against. I find this to be an easy solution, but it may not work for everyone’s application, as it would need to be called outside of the main program, through a C++ script, or through the python objects.