Re: Input Mask on Date for Year or Month Only



On Wed, 21 May 2008 18:28:32 -0700, B J wrote:

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?

"fredg" wrote:

On Tue, 20 May 2008 15:36:01 -0700, B J wrote:

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.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


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.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.



Relevant Pages

  • Re: Input Mask on Date for Year or Month Only
    ... Can I use an input mask to caputre only the year or only the month? ... If you wish to use the DateTime functions, then the field's datatype ... format, the stored value must contain the day as well. ...
    (microsoft.public.access.gettingstarted)
  • Re: Searching on DATETIME Fields
    ... The datetime datatype does not store the ... The format you see is created by the ... >>> The field I am querying is of DATETIME data type, ...
    (microsoft.public.sqlserver.server)
  • Re: Date Format
    ... Is the field data type definitely a DateTime? ... Input mask only constrains user keystrokes, ... can have any output format you want. ... > I open the form the date reverts back to the yyyymmdd format, ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Dates
    ... I have never ever had any problems with a date in ISO 8601 format. ... The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. ... System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) +260 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to Validate a Date Filed.
    ... I'm writing, and the fourth test is just getting fancy; ... IsValid As Boolean = True) As DateTime ... > You can validate a date using Regular Expressions. ... > objects and setting culture to a country that uses the date format you ...
    (microsoft.public.dotnet.framework.aspnet)