I had exactly the same problem, with only difference that I had a date column in my DB and wanted two fields for start date and end date to be able to display records which date is inside defined date range. With a help of mdomba I was able to do this quickly and painlessly. I’ll give you some advices on steps you should take to solve this problem, but you must try to implement it yourself over a weekend. If you want to get a complete, working example, then you have wait until Monday as I have it at my work and I don’t have access to those files from home! :]
Here is what you have to take care of:
Step 1: In your model definition file declare two new public variables (model attributes), for example $date and $time.
Step 2: Make sure, you add these variable names (without dollar sign) into your rules() method to (usually) last line, which ends with ‘safe’, ‘on’=>‘search’ and where you declare model attributes (variables) that can be search, but this also means that these variables are safe for massive assignment, which is what we want here. Because this will make Yii to send values entered by your user to your form, to these new fields along with other model attributes.
Step 3: Edit your form file to add two new input box, one as a datepicker and second for a time.
Step 4: Edit your view or controller, where you process input from the form (or search() method in your model file, if you use it for example for searching CGridView). Here, in place of $model->DATETIME which you used to access DATETIME field in your DB, you can now use $model->date and $model->time and do whatever you want with them.
The simplest solution would be to combine them together (with using PHP dot operator - .) and use in search. So, if originally in your search() method in your model you used:
to compare DATETIME field in DB with value from datetime field in the form, you can now use something like that:
to compare DATETIME filed with combined result from fields date and time in your form.
Write, if you have any further questions.