Re: Can you have one that is just mm/dd or mm/yyyy etc?




"LibbyChantel" <LibbyChantel@xxxxxxxxx> wrote in message
news:1146002568.852994.81030@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I need to store some data in this format: "mm/yyyy" as a Date or
DateTime. I can create SimpleDateFormat("mm/yyyy"), but when I do
format.parse() on "12/2001" it helpfully returns "December 1, 2001". I
need to store it as a DateTime of December 2001. Storing it as a String
is not an option.

Why is storing the date as a String not an option?

I think you'll need to go that route. Or you could put the month name in a
String and the year in an int and then bundle them together in a new Class
with a name like MonthYear; that class could have methods to get the year
and the month individually for convenience and to format the value however
you want it.

Another way to go would be store an arbitrary day with your month and year
and then just ignore the day portion but I don't much like that; it feels
like bad design to me although I can't articulate exactly what is wrong with
it.

Has anyone dealt with this kind of situation before and could point me
in the right direction to understand how to handle this?

This is a pretty unusual requirement, at least in my experience. In my view,
a date always includes a year, month and a day of the month; I wouldn't even
call the combination of year and month alone a date, really.

In business, you normally store a year, month and a day for every 'event',
like a bill payment or an insurance claim. Your reports may end up
summarizing by year and month but then the month/year combination would
normally be stored as a String, if it was stored at all. At least that's
been my experience.

Sorry I couldn't tell you what you wanted to her. Maybe someone else will
have a different take on this question.

--
Rhino


.



Relevant Pages

  • Re: MS SQL getDate() Function remove Time
    ... I strongly suggest not storing a date column as a string. ... Hi I am storing the coumn as datetime and not string. ... ....It should overwrite rowOld with rowNew, not insert rowNew as a new ...
    (comp.databases.ms-sqlserver)
  • Re: A97 - what would you do 99 times out of a hundred?
    ... > text value sounds to me as no different as a zero length string. ... just makes it *possible* to store a ZLS in that field. ... non-unique indexes are not going to be speeded up by storing a ZLS ...
    (comp.databases.ms-access)
  • Re: TextBox Validation for time only, not date
    ... A DateTime value is any point in time. ... To store a time only, the TimeSpan type should be used. ... String, but note that it expects a fixed format and disregards ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Windows does not recognize "." as decimal separator;
    ... Before storing the information I put the numerical value into some string ... I had some problems while trying to store blank in some fields so ... Set objDB = OpenDatabase ...
    (microsoft.public.vb.general.discussion)
  • Re: Are DateTime datatypes worth the aggravation?
    ... Although I am probably one of the most datetime puritans in these ... the range of datetime you can't even store Columbus's voyage to America ... Yes/No or what have you and as such are cast to strings. ... from string to datetime seem trivial. ...
    (microsoft.public.dotnet.general)