[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    Re: date problem
From:       Bob Hall <rjhalljr () starpower ! net>
Date:       2001-01-15 18:23:58
[Download RAW message or body]

>I got a problem in converting the Jan 21 2001 format to 2001-01-21
>I always got a null as result when i do date_format('Jan 21
>2001','%Y-%m-%d')
>
>can anyone help me with this

Sir, off the top of my head, I don't think there's a function for 
this. Date_format() converts from MySQL format to other formats, but 
not the other way around.

The following will reorder the parts of the date, but for converting 
'Jan' to '1', you're on your own. I would probably do it with a 
lookup table, but someone else may know a better way.

Concat(Substring_index(my_date, " ", -1), "-", 
Substring_index(my_date, " ", 1), "-", 
Substring_index(Substring_index(my_date, " ", -2), " ", 1))

Bob Hall

Know thyself? Absurd direction!
Bubbles bear no introspection.     -Khushhal Khan Khatak

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <mysql-thread61820@lists.mysql.com>
To unsubscribe, e-mail <mysql-unsubscribe-mysql=progressive-comp.com@lists.mysql.com>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic