Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109

    Unanswered: Having Some Problem

    I want to get only month inserted in a table

    and the query to insert month in every row suppose it have 22 rows in my table

    so it gets only month name like march or january ,whatever months but current month

    and i also want to convert data in this format 23-12-2010
    in mysql while fetching rows and inserting rows

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    look at the MySQL date functions

    ... dates are inserted using ISO format YYYY-MM-DD
    ....date values can be retrieved either as dates or formatted to whatever type you prefer. normally I'd suggest you do formatting in the presentation layer (ie your front end and leave the db to handle dates as it sees fit)

    ...having said that I hope you are storing dates in the date datatype
    Last edited by healdem; 06-15-10 at 04:07.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2010
    Posts
    6
    Quote Originally Posted by don_log View Post
    I want to get only month inserted in a table

    and the query to insert month in every row suppose it have 22 rows in my table

    so it gets only month name like march or january ,whatever months but current month

    and i also want to convert data in this format 23-12-2010
    in mysql while fetching rows and inserting rows
    You can fetch only mounth from datatime colum whit this query :
    Code:
     SELECT DATE_FORMAT(column_name, '%M') AS date FROM`tavleName`";
    }
    so, to convert dateformat from ISO format YYYY-MM-DD to DD-MM-YYYY you have to do this in your queries :

    Code:
     SELECT DATE_FORMAT(column_name, '%d-%m-%Y') AS date FROM`tavleName`";
    }
    You can check here about information for Date and Time Functions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •