I have a table of withdrawal requests that has a datetime field called 'create_date'

I need to query that table to see if a member has submitted a withdrawal request within the past 24 hours

If they have, I need just the most recent record within 24 hours that matches their member ID.

any suggestions.
I thought it was something like this, but it isn't working.

  SELECT wthd_id, gross, net, create_date
  FROM withdraw_recs
  WHERE mem_id = '$member_id'
  AND create_date<=date_sub(now(), INTERVAL -24 hour)
  ORDER BY create_date desc
  LIMIT 1

Recommended Answers

All 2 Replies

Shouldn't create_date be greater than or equal to now - 24 hours?

Yep... sure should... and it doesn't need the - in front of the 24...

Works perfectly.
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.