Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6814765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:43:38+00:00 2026-05-26T20:43:38+00:00

I have a table with a date field type date . What I am

  • 0

I have a table with a date field type date.

What I am trying to do is to do a comparison between the date from inside the table and the today date. If the date from the table is yesterday then insert the today date.

The thing I’m not sure about is how to insert the data in the database so I can make the comparison. here is what im thinking to do”

$d = time();
$x = mysql_querry("SELECT date FROM table where id = $id", $con);
while($y = myqsl_fetch_array($x)){
    $oldTime = $y['date']; 
}

if ($oldTime < $d){
$i = mysql_querry("INSERT INTO table (date) VALUES (CURDATE()) ", $con);
}

So, I’m not sure if $oldTime and $d can be compared like that, but I hope you guys get my point.

Any ideas?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:43:38+00:00Added an answer on May 26, 2026 at 8:43 pm

    You can’t do in that way because the CURDATE() function return a date in a format like 2011-11-11 while time() returns the number of seconds since the January 1 1970 00:00:00 GMT.

    Anyway you can change the format of the time() to look like the CURDATE() using the date() function in this way:

    date('Y-m-d', time())
    

    or even better, to get the current date, you can use just this line:

    date('Y-m-d')
    

    To conclude, you can do the if in this way:

    if( strtotime($oldTime) < strtotime(date('Y-m-d')) )
    

    or even better:

    if( strtotime($oldTime) < strtotime('now') )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the field: APP_DATE (smalldatetime) I'm doing this query: INSERT INTO table (TYPE,
If I have a field in a table of some date type and I
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a MySQL table where there is a 'date_added' (date) field, 'time_added' (time)
I have a table in SQL Server 2005 which has a date time field.
I have a date field in the database table of this format 2012-02-1.i need
I have a SQL table with a date field defined as char(8), or 20090609,
I have MySQL table with the following structure: +---------+--------------+------+-----+---------+----------------+ | Field | Type |
Ok I have a temporary table with 135000 rows, I'm trying to insert some
I have a table with a field of type bigint. This field store a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.