Daft question time...

Are you reading the date/time from user input or from the system clock?

If its the later there are procedures that extract the component parts for you (decodeTime and decodeDate). If its the former and its a gui, why not use the date/time selectors?

As I said... probably a daft question... depends on what you want to achieve.