View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 10:06 AM
Axel Schwenke
 
Posts: n/a
Default Re: mySQL date querying

"davidjohnlong@googlemail.com" <davidjohnlong@googlemail.com> wrote:
>
> I'm trying to convert the following query into mySQL, this currently
> working with MS SQL although not with mySQL.
>
> SET DATEFORMAT dmy declare @d datetime set @d = '01/12/2007' select *
> from matrix.subscriptions where @d between startdate and enddate
>
> Anyone got any idea how this can be done within mySQL


SET @d = STR_TO_DATE('01/12/2007', '%m/%d/%Y');
SELECT ... WHERE @d BETWEEN startdate AND enddate;

RTFM on STR_TO_DATE() and friends:
http://dev.mysql.com/doc/refman/5.0/...functions.html


XL
--
Axel Schwenke, Support Engineer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Reply With Quote