Re: Input Mask on Date for Year or Month Only



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

.



Relevant Pages

  • Re: Converting and formatting DATE field
    ... SQLServer does not have a date only datatype, therefore it will store a time ... If you don't specify the time portion when the datetime is inserted ... > I would like to be able to format this date and show only ...
    (microsoft.public.sqlserver.programming)
  • 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: simple way to convert 1900-01-01 17:12:00.000 to 5:12pm?
    ... datatype is datetime. ... i want to the convert the start_time column into a format that only ... has the hour and minutes plus AM/PM ...
    (comp.databases.ms-sqlserver)
  • 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)