Jump to content

Comparing two date values.


mat-tastic

Recommended Posts

Hey Guys,

 

I have never had to do this before, but someone wants me to help them.

 

I have done the rest of the coding for the system, however:

 

The client has to renew their server (TS Server) and two weeks after that the renew deadline day, they want the servers to be removed if they have not renewed in that two weeks.

 

How would I work out when two weeks has passed from the renew date?

 

e.g two weeks after 2008/06/05

Link to comment
Share on other sites

i have just been working on a somewhat similar issue myself.

 

some question need to be answered first for the easiest solution.

 

1. what version of php are you using?

2. how is the date stored now?

3. how automated does this need to be?

  (i.e. is this script going to run on it's own at a given time?, or will the user manually run the script?)

 

I ask what version of PHP you have because there are inherent classes for dealing with Date and Time in 5.2.x

 

Answer those up and we can figure something out for you.!

 

-C

 

 

Link to comment
Share on other sites

Sorry not to sure i understand what you mean?

 

The script would be run manually.

 

It just needs to check what date it would be if it was two weeks after the renewal data in the database, then compare that to the current date.

 

if the current date is equal or past it, it kills the server.

Link to comment
Share on other sites

SELECT `account` FROM `table` WHERE DATE_ADD(`expires`, INTERVAL 2 WEEK) > NOW()

 

Any rows that are returned have an `expires` value older than 2 weeks.

 

if expires + 2 week > now() then the records are younger than 2 weeks

 

for older than 2 weeks you are looking for

 

expires < NOW() - INTERVAL 2 WEEK

Link to comment
Share on other sites

SELECT `account` FROM `table` WHERE DATE_ADD(`expires`, INTERVAL 2 WEEK) > NOW()

 

Any rows that are returned have an `expires` value older than 2 weeks.

 

if expires + 2 week > now() then the records are younger than 2 weeks

 

for older than 2 weeks you are looking for

 

expires < NOW() - INTERVAL 2 WEEK

 

Thanks to both of you, I will report back shortly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.