List:General Discussion« Previous MessageNext Message »
From:Roger Baklund Date:October 17 2003 1:06am
Subject:Re: from char to Date routine
View as plain text  
* 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

Thread
from char to Date routineKim G. Pedersen17 Oct
  • Re: from char to Date routineRoger Baklund17 Oct
  • Re: from char to Date routinePaul DuBois17 Oct
    • msaccess frontendColleen Dick18 Oct
      • Re: msaccess frontendMartin Lancaster19 Oct
  • Re: msaccess frontendinfo18 Oct
Re: from char to Date routineRoger Baklund17 Oct
  • Re: from char to Date routineDirector General: NEFACOMP17 Oct
Re: msaccess frontendTbird67ForSale19 Oct