Using LIKE '%%' with dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luckilian
    New Member
    • Apr 2007
    • 12

    #1

    Using LIKE '%%' with dates

    Hi there i have a problem with on mysql query ..
    i want to extract all the data from mysql table within 2 months ..

    [CODE=SQL]
    SELECT
    data_curenta,co d_produs,denumi re,cantitate,pr et,round((canti tate*pret),2) as 'Total',firma
    FROM procesare
    WHERE
    tip_actiune='in trare'
    AND
    data_curenta >= '2007-04-03'
    and
    data_curenta <= '2007-05-05'
    ORDER by cod_produs asc;
    [/CODE]

    i want to do something like that only with months :

    data_curenta like '%2007-04%' and data_curenta like '%2007-06%'


    i don't know how to do it .Pls help
    Last edited by Atli; May 20 '07, 08:00 AM. Reason: Made query more readable
  • luckilian
    New Member
    • Apr 2007
    • 12

    #2
    try
    where data_curenta >= '2007-04-01' and data_curenta <= '2007-06-31'
    :P

    Comment

    • pradeep kaltari
      Recognized Expert New Member
      • May 2007
      • 102

      #3
      Originally posted by luckilian
      Hi there i have a problem with on mysql query ..
      i want to extract all the data from mysql table within 2 months ..

      SELECT data_curenta,co d_produs,denumi re,cantitate,pr et,round((canti tate*pret),2) as 'Total',firma FROM procesare WHERE tip_actiune='in trare' AND
      data_curenta >= '2007-04-03' and data_curenta <= '2007-05-05' ORDER by cod_produs asc;"

      i want to do something like that only with months :

      data_curenta like '%2007-04%' and data_curenta like '%2007-06%'


      i don't know how to do it .Pls help
      Hi,
      Try something like this:
      Code:
      SELECT * 
      FROM procesare 
      WHERE tip_actiune='intrare' AND
      data_curenta >= ( SELECT MIN(data_curenta) FROM procesare WHERE data_curenta LIKE '2007-04%') AND data_curenta < ( SELECT MIN(data_cureta) FROM procesare WHERE data_curenta LIKE '2007-06%' ) ORDER by cod_produs asc
      I hope this solves your problem.

      Regards,
      Pradeep

      Comment

      • luckilian
        New Member
        • Apr 2007
        • 12

        #4
        tnx .. it work . tnx a lot

        Comment

        Working...