Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    If Statemates and the Date

    Hi,
    I'm tring to do what i thought would be a simple task,
    just check mysql data base to see if any records are new for today,

    code:
    If (day(rs2("date_added"))) = (day(date())) Then


    both values = 17, so i'm not sure what the problem is.
    but the statement seems to think everything in the list being pulled it new. and there should only be about two new items, i checked the table to be sure..

    any ideas?

    thanks in advance for your time!
    -Ken

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Try something like this, it works for MS SQL not sure about My SQL I think dates might get a bit different. In any case it's better to just pull the records you want to begin with.

    Code:
    SQLstr="SELECT * FROM tableName WHERE dateField > '" & formatDateTime(now()-1,2) & " 11:59 PM'"
    Basscyst
    Last edited by Basscyst; 08-18-2005 at 02:53 AM.
    Helping to build a bigger box. - Adam Matthews

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Lets mysql do this work:

    Code:
    SELECT * FROM tablename where LEFT(datefield,10) = CURDATE()
    for yesterday:

    Code:
    SELECT * FROM tablename where LEFT(datefield,10) = DATE_ADD(CURDATE(), INTERVAL -1 DAY)
    cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •