Input Mask on Date for Year or Month Only

B

B J

I want to have either a single classification for Year-Month, or a field for
year, and a field for Month.

I'd like to be able to use the Date/Time functions to compare these to other
data.

Can I use an input mask to caputre only the year or only the month?

Specifically for the month, I'd like the user to be able to enter "August"
or "08" into the field - not sure how to do this if I used "Integer" or
"Text" as the field type.

If anyone has some thoughts on this, they'd be much appreciated.

Thanks;
Ben.
 
F

fredg

I want to have either a single classification for Year-Month, or a field for
year, and a field for Month.

I'd like to be able to use the Date/Time functions to compare these to other
data.

Can I use an input mask to caputre only the year or only the month?

Specifically for the month, I'd like the user to be able to enter "August"
or "08" into the field - not sure how to do this if I used "Integer" or
"Text" as the field type.

If anyone has some thoughts on this, they'd be much appreciated.

Thanks;
Ben.

Why??????

If you wish to use the DateTime functions, then the field's datatype
should be DateTime.
A DateTime datatype value must be a valid date, which includes the
Month, Day, and Year, so while you can DISPLAY a date in month/year
format, the stored value must contain the day as well.

What you can do is have the user enter the date value in mm/yyyy or
mm-yyyy format, i.e. 08/2008 or 08-2008. Access will then interpret
and store that value as 08/1/2008. Do not use an Input Mask. Set the
Format property of the control to mm/yyyy or mm-yyyy. You will be able
to use any of the Access Date functions.

Other than that, you could create a Text datatype field, enter the
"08/2008" or "08-2008" as text. But then you will no longer be able to
use any of the date functions without first converting the text back
into a valid Datetime value which means giving it a day value.
The same holds true if you used separate month and year fields.
 
B

B J

Yes, thank you - I needed to clarify what I needed. Upon further thought, a
single column for Year/Month is all I really need.
I know there will have to be a value in "Day", but that's irrelevant to me,
as would the decimal places for "Time".

I can have the user enter it as either "August, 2008", or "08/2008", then,
which is largely what I was driving at.

How do you change the default display, then? Can I change it to a custom
"yyyy-mm" format?
 
F

fredg

Yes, thank you - I needed to clarify what I needed. Upon further thought, a
single column for Year/Month is all I really need.
I know there will have to be a value in "Day", but that's irrelevant to me,
as would the decimal places for "Time".

I can have the user enter it as either "August, 2008", or "08/2008", then,
which is largely what I was driving at.

How do you change the default display, then? Can I change it to a custom
"yyyy-mm" format?

With the field a DateTime datatype you can use an input mask of
00/0000
which will accept an entry, for example, of 05/2008 (the user must
enter a 2 digit month number and a 4 digit year). The actual value
will be stored as 05/1/2008.
If you then set the Format property of the control on the form to
yyyy/mm
it will display as 2008/05.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top