Jump to content

datetime search


matfish

Recommended Posts

  • 3 weeks later...
if you're wanting to manipulate with PHP, just use the following for one year from today:
[code]
<?php
// insert this value into the datetime field
$date = date('Y-m-d', strtotime("today + 1 year"));
?>
[/code]

if you'd rather do it with mySQL directly, you can do the following query:
[code]
INSERT INTO tableName (dateCol) VALUES (DATE_ADD(CURDATE(), INTERVAL 1 YEAR));
[/code]

hope this helps
Link to comment
Share on other sites

[quote author=matfish link=topic=104492.msg428501#msg428501 date=1157469633]
Hi - thank you - Works a treat!

I gather if I wanted to add on months the same would apply?

Much appreciated!
[/quote]

yes, check out the INTERVAL keyword in the mysql manual. you can use it to declare anything from seconds to years to whatever.
Link to comment
Share on other sites

[quote author=matfish link=topic=104492.msg428516#msg428516 date=1157470287]
how about if I was using the php manipulation way?
[/quote]

same idea. read up in the manual on strtotime(). it will handle practically any human readable date format or interval and calculate the differences.

good luck
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
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.