www.webdeveloper.com
Results 1 to 5 of 5

Thread: change sql date format

  1. #1
    Join Date
    Dec 2005
    Posts
    12

    change sql date format

    hello every one i m working on very simple database program for my office but i m having trouble with date format in phmysql 2.61 i just wanna change dafault value of date faild
    it's showing " 0000-00-00 " but i want " 00-00-0000 " day-month-year ...................... is it possible to change this dafault value thru any config file of sql ?
    please help me
    Last edited by fsaghar; 02-26-2006 at 06:47 AM.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,316
    I do not think you can change the way the database stores the data, but it's easy to change how it's output:
    Code:
    SELECT DATE_FORMAT(`date_column`, '%m-%d-%Y) FROM `table_name`;
    If you need to insert/update a mm-dd-yyyy value:
    Code:
    INSERT INTO `table_name` (`date_column`) VALUES (STR_TO_DATE('02-22-2006', '%m-%d-%Y));
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Dec 2005
    Posts
    12
    thanks for ur reply but this command isn't working for me at all
    i use this is sql replied [QUOTE]
    DATE_FORMAT(`date`,
    '%d-%m-%y')
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    \0\0d\0-\0\0m\0-\0\0y
    i m using this ............... structure = date type = date null = no dafault= 0000-00-00
    please help me how to solve this problem
    i tried this command SELECT DATE_FORMAT(`date`, '%d-%m-%y) FROM `table_name`;
    SELECT * FROM `abl
    but it's still showin 00day-month-year 0000-00-00

    please help me

  4. #4
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    please clarify, what exactly did you put into your sql statement?
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  5. #5
    Join Date
    Dec 2005
    Posts
    12
    let me explain what i m trying to make ............... i m working on a bank database for my office wanna make statment but "date" is really trouble for me ..............
    i just wannt date format day-month-year ...............

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles