Reply
if statement with dates
Old 05-01-2008, 03:55 AM if statement with dates
Junior Talker

Posts: 3
hello, im using a delete function but some how i want to use an if statement; for example if the current server date matches the date from a row from a database table and if the date is 2days from the current date it can't be delete.
panther786 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 05-02-2008, 10:13 AM Re: if statement with dates
addonchat's Avatar
Skilled Talker

Posts: 97
Name: Chris Duerr
Sounds like it's just a SQL issue, not a PHP issue. Check out:
http://dev.mysql.com/doc/refman/4.1/...functions.html

The first example (the SELECT example) should give you all that you need -- You'll basically just be changing the interval (from 30 days to 2 days), the column name, and using DELETE instead of SELECT
__________________
Chris Duerr
AddonChat Java Chat Software
http://www.addonchat.com/ - Affiliate Program
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-02-2008, 10:54 AM Re: if statement with dates
nickohrn's Avatar
Weightlifting CS Student

Posts: 505
Name: Nick Ohrn
panther786 - I'm not entirely sure I understand your question, but I'll try to give you an answer.

It looks like you're trying to not delete a record if the day is within two days of the current date. Assuming that is the case, you just need to calculate the time difference between the record being deleted and the current time. To do so, you can just implement a time_difference function and check out the value to see if it is less then a certain amount. See the php time function page and search for difference. As the other poster said, you can also do this in SQL, but I didn't know if you had a reason for not wanting to do it that way.
__________________
Plugin-Developer.com - Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
nickohrn is offline
Reply With Quote
View Public Profile Visit nickohrn's homepage!
 
Reply     « Reply to if statement with dates
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12495 seconds with 13 queries