Me, I will say that such a function should be added as a feature request since it doesn't exist. MySQL 4.1.1 introduces MAKE_DATE() The following can be read from http://www.mysql.com/doc/en/Date_and_time_functions.html
MAKEDATE(year,dayofyear) Returns a date, given year and day-of-year values. dayofyear must be greater than 0 or the result will NULL. mysql> SELECT MAKEDATE(2001,31), MAKEDATE(2001,32); -> '2001-01-31', '2001-02-01' mysql> SELECT MAKEDATE(2001,365), MAKEDATE(2004,365); -> '2001-12-31', '2004-12-30' mysql> SELECT MAKEDATE(2001,0); -> NULL But I really don't see how useful is the above function since it is not easy to calculate the day of year value. Instead it should be changed into or extended to support returning a date (in the MySQL format yyyy-mm-dd) with arguments being a date and a format like the one Kim asked. Thanks Emery ----- Original Message ----- From: "Roger Baklund" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: "Kim G. Pedersen" <[EMAIL PROTECTED]> Sent: Friday, October 17, 2003 03:06 Subject: Re: from char to Date routine > * Kim G. Pedersen > > I looking for a way to convert a datestring to date value > > example > > UnknowFunction('23.03.68','dd.mm.yy') -> unixtimestamp > > > > In oracle we have > > to_date('23.03.68','dd.mm.yy') > > > > I have search the net for hours without luck. > > Unix timestamps starts at 01/01-1970, your example will return 0. > > MySQL has the UNIX_TIMESTAMP() function: > > <URL: http://www.mysql.com/doc/en/Date_and_time_functions.html#IDX1365 > > > You have to format a correct mysql date string: > > SELECT UNIX_TIMESTAMP('1970-03-23'); > > You can change the format of the date by using string manipulation > functions: > > SET @a = "23.03.70"; > SELECT UNIX_TIMESTAMP( > CONCAT('19', > MID(@a,7,2),'-', > MID(@a,4,2),'-', > MID(@a,1,2))); > > -- > Roger > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]