Page 1 of 1

Storing date as m/Y

Posted: Mon Aug 13, 2007 5:58 am
by aceconcepts
Hi,

I have a field titled startDate of data type DATE and has an input mask of 0000-00-00.

What I would like to do is store a date as mm/yyyy (08/2007).

How can I do this?

Posted: Mon Aug 13, 2007 6:07 am
by superdezign
You'd just... do it. There's not much reason to, though. You could always store it as YYYY-MM-DD and display it as mm/yyyy. If you store it as mm/yyyy, you'll have problems with ordering.

Posted: Mon Aug 13, 2007 9:44 am
by onion2k
For things like credit card expiry dates where there's only a month and year I store them as a date field, but always insert them as the first of the month the user entered. For example, if the user updates their card to expire on 08/2010 it goes into the database as 2010-08-01. It's not ideal, but it works.

Posted: Mon Aug 13, 2007 9:52 am
by aceconcepts
Hi onion2k,

Yeah thats what I ended up doing with the date.

Thanks for your posts.