Jump to content

[SOLVED] Returning Boolean from Date/Time field


kmaid

Recommended Posts

Hi all,

 

My current PHP project requires me to cache data for 5 minuets after which IF the data is requested again the data needs to be requested from another server.

 

I store the DateTime when the data was last requested and what I would like to do is make an SQL query which returns true/false depending on if 5 minuets have passed since the stored DateTime.

 

Is this possible and are there any examples of this or should I just convert the DateTime into a php date time and do it in PHP?

 

Thanks

Kmaid

 

**EDIT**

My bad didnt read sticky mysql version 5.0.51b-community-nt

Link to comment
Share on other sites

SELECT IF(NOW() - dateTimeRequested < 300, TRUE, FALSE) FROM table

 

edit

 

it seems that even

 

SELECT NOW() - dateTimeRequested < 300 FROM table

 

will work

(and of course 5 minutes is 300 seconds not 600 )

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.