I don't think a formula can directly change the fill color of a cell. However, you can use a formula that outputs the actual name of the color you want (this formula assumes that your date is in cell
Then, you will have to use conditional formatting to actually color the cell based on the name of the color. For example, set conditional formatting so that the word
red changes the fill color to Red. This way, you won't have a complicated formula in the conditional formatting. The calculation will take place in the formula actually in that cell. If you don't want the names of the colors to be visible, you can set the conditional formatting so that it also changes the font color to the same as the fill color ("Invisible Version" in the example).
If you are trying to color the cells that actually contain the dates, the formula logic will need to be contained inside of the conditional formatting. This is shown in the "One Column Version" in the example.
Here is an example spreadsheet: https://dl.dropbox.com/u/3488338/DueDateFormula.xlsx