Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to enter Just the year or month and year in a date field

Status
Not open for further replies.

McLiguori

Technical User
Mar 27, 2003
90
IT
In a personnel database I have fields for BirthDate and DeathDate. For some members only the year, or the month and year is known for either or both of these fields. The fields are Date fields and are formatted as dd-mmm-yyyy with an input mask of: 00\->L<LL\-0000;0;_

Is there a way I can enter just the year, or the year and the month. Every time I try, I get an error message that forces me to enter the complete information, e.g. 01-Jan-1799. If I leave the date or the month blank, I get the error message.

If date fields must be completely filled is there a workaround for this situation?

Thanks.

Ligs
 
Try..
Code:
99\->?<??\-0000;0;_

________________________________________________________
Zameer Abdulla
Help to find Missing people
Even a thief takes ten years to learn his trade.
 
Thanks Zameer. I tried it and I still get the same 'The value you entered is not valid for this field" error message. I changed it both in the form control properties and in the table structure. No go.
 
If you are not doing calculation with these dates then change fieldtype = Text. i will accept.

You may need to create a function to convert these incomplete dates to complete one when you do calculation.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Even a thief takes ten years to learn his trade.
 
Thanks for the suggestion. But, I am using them to calculate age, so changing them to text will not help.
 
Couldn't you just remove the input mask??

With your date field formatted dd-mmm-yyyy, if you enter a month/year combination: 04/2001 the date will be represented as 01-Apr-2001....

I don't see a solution for entering a year only.



Si hoc legere scis, nimis eruditionis habes
 
Thanks CosmoKramer. I tried it but still no go. I tried taking the formatting and input mask out both in the table structure and the form and still no go. If I enter just the year, I still get that error.

P.S. I know how to read it... but I am not very erudite! (at least not in getting Access to do what I need it to do!)
 
But, I am using them to calculate age, so changing them to text will not help.

If you store the date as a text field there's nothing to stop you from converting it back to a date to perform calculations.


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
If you are using the value to calculate age (or almost anything else), you will need an actual date to do the calculation anyway. A real date is NOT stored as separate month, day and year, and if you try to enter a partial date, the missing values will default.

You could store separate day, month and year fields, but then whenever you did a calculation you would need to convert what you have to a real date anyway.
 
Thanks. I'll try using a text field then converting it to a date.
 
Are you using a form to enter these dates?? If so, remove input masks from both the form and the table definition for that field.

In my limited testing, I was able to enter dates in multiple different formats into a Date/Time field formatted as dd-mmm-yyyy with no input masks and have them display in the proper way. Like I stated above, when I entered only a mm/yyyy combination it assumed the first of that month.....

Si hoc legere scis, nimis eruditionis habes
 
Thanks CosmoKramer,

It worked like you said. However, because in a list of over 27,000 names, a default to the first of the month for an entry of mm/yyyy leads to confusion. One cannot tell if its a default entry of the first of the month, or if it is REALLY the first of the month. I created a separate field with a date field formatted as yyyy and no input mask. It seems to have done the job. Its one more field, but it gets the job done. THANKS AGAIN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top