Hi

There are two aspects to dates, and your questions include parts of both.

When MySql stores dates you have a choice of column types

http://dev.mysql.com/doc/mysql/en/DATETIME.html

has the details

If you just need to store dates then the DATE type will suit your needs. You
just specify it as DATE

When you insert dates you need to insert them in the format yyyy-mm-dd ie
2004-12-31

When you retrieve them they default to the same format.

If you wanted to retrieve them in a different format that is when you use
DATE_FORMAT(date,format)

eg

INSERT  INTO table1
    (
    field1
    , date_field
    , field2
    )
VALUES
    (
    "some data"
    , "2004-02-12"
    , "some more data"
    );


then to retrieve the data

SELECT DATE_FORMAT(date_field ,"%M %D %Y")
            FROM table1

would return "February 12th 2004" instead of "2004-02-12"

Hope this clarifies it......

Come back to me if not

Peter









> -----Original Message-----
> From: David Blomstrom [mailto:[EMAIL PROTECTED]
> Sent: 22 June 2004 07:40
> To: [EMAIL PROTECTED]
> Subject: New to Dates - Plain English Please
>
>
> I  haven't worked with dates yet and wondered if
> someone could give me an overview in plain English.
>
> At the moment, I'm working on a table with a column of
> dates in this format:
>
> March 2, 2003
> July 7, 2004
>
> If I understand the Manual, the correct format for
> these dates in a MySQL table would be like this:
>
> 03-02-2003
> 07-07-2004
>
> Am I right?
>
> When I create a DATE field, do I need to designate a
> Length/Value, Attribute, etc.? If so, how long is
> 07-07-2004 - 8 characters, or ten?
>
> And is it also correct that you can manipulate dates
> in this format to display in other formats? For
> example, 03-02-2003 could be displayed as March 2,
> 2003?
>
> I THINK this is what the Manual is talking about
> here...
>
> DATE_FORMAT(date,format)
>     Formats the date value according to the format
> string. The following specifiers may be used in the
> format string:
>     Specifier         Description
>     %a        Abbreviated weekday name (Sun..Sat)
>     %b        Abbreviated month name (Jan..Dec)
>     %c        Month, numeric (0..12)
>     %D        Day of the month with English suffix (0th,
> 1st, 2nd, 3rd, ...)
>     %d        Day of the month, numeric (00..31)
>     %e        Day of the month, numeric (0..31)
>
> If so, this must be something you do with PHP, right?
>
> I guess the most important thingn I need to know is
> what format to put my dates in. If 07-07-2004 is the
> standard format, and if I can print/display that in
> various ways, then I can figure the rest out when I
> get to it.
>
> Thanks.
>
>
>
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!
> http://promotions.yahoo.com/new_mail
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to