Fixed checking if date exists in key name (postgres)

It was assuming ```len(name_parts) >= 3```

Code is a bit verbose, I can improve it by inlining the ```month``` and ```year``` values in the check itself, but I thought it would be easier to read by explicitly assigning it to those variables like you had before.  
Main change is it now checks for the length of ```name_parts``` as another condition to add the date information/