* 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:

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]

Reply via email to