You might also want to check the EXTRACT() function - it returns the desired field from datetime value.