MySQL Forums
Forum List  »  Oracle

Re: Useing Oracle developmer 2000 as front-end
Posted by: Smita Bansal
Date: February 14, 2005 01:27AM

Hi,

We had done some research on data type conversion in MySQl. I am sending you the problems and the suggested solutions. See if this helps.

Problem: to_char do not work

Solution:
DATE_FORMAT(date,format) : Formats the date value according to the format string(section 6.3.4 for date and time function) SELECT DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');
-> 'Saturday October 1997'
mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00', '%H:%i:%s');
-> '22:23:00'
mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00',
'%D %y %a %d %m %b %j');
-> '4th 97 Sat 04 10 Oct 277'
mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00',
'%H %k %I %r %T %S %w');


Problem:to_date do not work(a)

Solution:
STR_TO_DATE(str,format)
This is the reverse function of the DATE_FORMAT() function. It takes a string str, and a format string format, and returns a DATETIME value. The date, time, or datetime values contained in str should be given in the format indicated by format. For the specifiers that can be used in format, see the table in the DATE_FORMAT() function description. All other characters are just taken verbatim, thus not being interpreted. If str contains an illegal date, time, or datetime value, STR_TO_DATE() returns NULL.
mysql> SELECT STR_TO_DATE('03.10.2003 09.20', '%d.%m.%Y %H.%i')
-> 2003-10-03 09:20:00
mysql> SELECT STR_TO_DATE('10rap', '%crap')
-> 0000-10-00 00:00:00
mysql> SELECT STR_TO_DATE('2003-15-10 00:00:00', '%Y-%m-%d %H:%i:%s')
-> NULL


GET_FORMAT :: Returns a format string. This function is useful in combination with the DATE_FORMAT() and the STR_TO_DATE() functions. mysql> SELECT DATE_FORMAT('2003-10- 03', GET_FORMAT(DATE, 'EUR')
-> '03.10.2003'
mysql> SELECT STR_TO_DATE('10.31.2003', GET_FORMAT(DATE, 'USA'))
-> 2003-10-31

Hope this helps!!!
Regards,
Smita

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Useing Oracle developmer 2000 as front-end
3497
February 14, 2005 01:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.