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.

 
Go Back  dBforums > Database Server Software > MySQL > Having Some Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-15-10, 02:43
don_log don_log is offline
Registered User
 
Join Date: Jun 2008
Location: pakistan
Posts: 109
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
Reply With Quote
  #2 (permalink)  
Old 06-15-10, 03:01
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton

Last edited by healdem; 06-15-10 at 03:07.
Reply With Quote
  #3 (permalink)  
Old 06-15-10, 06:32
saviola saviola is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On