First we'll assume dates in the Gregorian calendar that fall between 01/01/1800 to 12/31/9999. All math must be 16-bit integer math. If you use floating point numbers, the answer won't be correct. In the PLC-5, you can use a series of CPT commands. For example, the first one: Dest=N7:10 Expression=(14.0 - S:20) | 12.0. The next CPT Dest= N7:11 Expression= S:18 - N7:10. The next CPT Dest= N7:12 Expression=(S:19 + (12 * N7:10)) - 2. And the final CPT Dest= N7:13 Expression= ((((S:20 + S:18) + (S:18 | 4)) - (S:18 | 100)) + (S:18 | 400)) + (((31 * S:19) | 12) MOD 7).
N7:13 contains the answer. 0=Sunday thru 6=Saturday.