List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 14 1999 6:38pm
Subject:Re: Saving dates as YYYYMMDD
View as plain text  
On Tue, 1999-09-14 10:11:51 -0700, Mike Machado wrote:
> Claudia M. Castaneda wrote:
> 
> > Is it possible to have the DB save the date as YYYYMMDD and the time as
> > HHMMSS using the date and time types respectively and not return a
> > formated string, i.e "YYYY-MM-DD" or "HH-MM-SS" ?
[...]
> If you store your dates as a normal mysql date/time column, you can use the
> format_date() function in your selects to put the date/time in any format
> you want. the reference manual as all the format characters for this
> function. Its a very useful thing that I use a lot.

Just a typo: The function's name is DATE_FORMAT(), not format_date().

And a note from chapter "7.2.6 Date and time types":
| MySQL automatically converts a date or time type value to a number
| if the value is used in a numeric context, and vice versa.

Examples:
+---------------------+  +----------------+
| NOW()               |  | 0+NOW()        |
+---------------------+  +----------------+
| 1999-09-14 20:36:48 |  | 19990914203651 |
+---------------------+  +----------------+

+--------------+         +----------------+
| CURRENT_DATE |         | 0+CURRENT_DATE |
+--------------+         +----------------+
| 1999-09-14   |         |       19990914 |
+--------------+         +----------------+

+--------------+         +----------------+
| CURRENT_TIME |         | 0+CURRENT_TIME |
+--------------+         +----------------+
| 20:35:58     |         |         203554 |
+--------------+         +----------------+

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
Saving dates as YYYYMMDDClaudia M. Castaneda14 Sep
  • Re: Saving dates as YYYYMMDDMike Machado14 Sep
    • Re: Saving dates as YYYYMMDDMartin Ramsch14 Sep
  • Re: Saving dates as YYYYMMDDChristian Mack14 Sep
    • Re: Saving dates as YYYYMMDDDaniel E. White15 Sep
      • Re: Saving dates as YYYYMMDDMichael Widenius17 Sep
  • Re: Saving dates as YYYYMMDDChristian Mack15 Sep
    • Re: Saving dates as YYYYMMDDMartin Ramsch16 Sep
      • Re: Saving dates as YYYYMMDDMichael Widenius17 Sep