I'm assuming you're talking a web page/site? Your question doesn't actually provide any context.
Best practice is to have a date field that users can either enter the date manually or click on a 'calendar' icon to then be presented with a small calendar from which they can select the appropriate date.
I did a quick mockup to show you what I mean:
In the above example users can click in the field and enter the date. Or they click on the calendar icon (see below image) to be able to select the appropriate date. Users can move forward and backward within the calendar to get to the date they need.
Now, if the user needs flexibility in terms of what they're choosing, the usual method is to just use drop down lists for each of the fields. In your scenario you'd have a couple of options:
- Have all three fields as drop-down lists and ensure the Year field is mandatory. The user can then choose either one or both of the optional Month and Day fields.
- Present the user with an option first to choose the format they want to enter and then, based on their choice, have the appropriate fields appear with all of them being mandatory.