| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

08-04-06, 06:45
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 27
|
|
|
Dateformat: YYYY-MM
|
|
Hi,
(how) can i create a column with a format like "YYYY-MM"?
|
|

08-04-06, 07:07
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
CHAR(7)
what do you need it for? there might be another way to get what you want
|
|

08-04-06, 07:20
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 27
|
|
|
|
Hi,
i want to store values, which are related to a month in a year. The exact day is not interesting. My first idee was to use the date format as providesd by mysql (YYYY-MM-DD), an fill the DD part with a dummy value. But if someone else will mantain this later, surely the question will come "why did you use always a dummy for DD". Therefore i dont want to store data which has no sense.
|
|

08-04-06, 07:28
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
well, as a matter of fact, you can store values in a DATE column using 00 as the day!!
it's certainly not standard, but mysql lets you do it, check the manual for examples
otherwise, i would use two columns, a SMALLINT for the year and a TINYINT for the month
|
|

08-04-06, 07:37
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 27
|
|
hi,
that's both not the solution i hoped for, but if ther's no other i think i'll choose the one with two columns
Thanx
roli
|
|

08-04-06, 07:43
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
what were you hoping for?
and what's so wrong with a DATE column with values '1998-12-00'? 
|
|

08-04-06, 07:58
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 27
|
|
Quote:
|
Originally Posted by r937
what were you hoping for?
|
I thought there would be a way to define a column with a format like "YYYY-MM"
Quote:
|
Originally Posted by r937
and what's so wrong with a DATE column with values '1998-12-00'? 
|
I dont want to store datn which has no information (-00). If there's no direct way provided by the DB, i'll have to find on by myself (or with your help: two clumns).
Further or later someone (or me) will think "what the hell does -00 meen?"
|
|

08-04-06, 08:06
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
well, you could always just show them the page in the manual where -00 is explained

|
|

08-04-06, 08:17
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 27
|
|
You're right, but this solution just work's as long as my DBA sets the SQL-Modus to NO_ZERO_IN_DATE.
Two coulm's will work for ever 
|
|

08-04-06, 09:29
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
yes, but only for approx 63,000 years, unless you plan ahead now and use INTEGER instead of SMALLINT

|
|

08-04-06, 11:14
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 27
|
|
Ok, if that's gonna happen i'll quit 
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|