Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

mySQL date diff help

Options
  • 10-10-2006 11:16am
    #1
    Registered Users Posts: 771 ✭✭✭


    Hi

    I need to select all records from a table, within a year from the last date

    first query gives me latest Bulletin
    select B_Date from Bulletin order by Bulletin Desc limit 1

    then i want to subtract 12 months from this date
    and use this as the guage so

    lastDate = DateAdd("m",-12,LastBullRS("B_Date"))

    now i want to select * from Bulletin order by Bulletin Desc where "....

    and now im stuck
    where B_Date > lastDate returns an error


    any idea?


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    DateAdd - is that meant to be a function of some sorts?

    Plus what format is B_Date stored in your db like? (0000-00-00???)


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    What error do you get?


  • Registered Users Posts: 771 ✭✭✭whiteshadow


    select * from Bulletin order by Bulletin Desc where B_Date > '2005-9-5')
    Microsoft OLE DB Provider for ODBC Drivers error '80040e09'

    [MySQL][ODBC 3.51 Driver][mysqld-4.1.21-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where B_Date > '2005


  • Registered Users Posts: 771 ✭✭✭whiteshadow


    Ph3n0m wrote:
    DateAdd - is that meant to be a function of some sorts?

    Plus what format is B_Date stored in your db like? (0000-00-00???)

    Yes an asp function that gives me the date
    then i convert to 0000-00-00 format and run the query


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    shouldnt the query not be

    select * from Bulletin where B_Date > '2005-9-5' order by Bulletin Desc

    ??


  • Advertisement
  • Registered Users Posts: 771 ✭✭✭whiteshadow


    Ph3n0m wrote:
    shouldnt the query not be

    select * from Bulletin where B_Date > '2005-9-5' order by Bulletin Desc

    ??

    shaking head with shame.


    thank you.


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    no problem, glad to help


Advertisement