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 8760889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:09:19+00:00 2026-06-13T15:09:19+00:00

$createDate = mktime(0,0,0,10,28,date(Y)); $selectedDate = date(‘d-m-Y’, ($createDate)); $active = 0; $sql = UPDATE Session

  • 0
$createDate = mktime(0,0,0,10,28,date("Y"));
$selectedDate =  date('d-m-Y', ($createDate));
$active = 0;
$sql = "UPDATE Session SET Active = ? WHERE SessionDate <= ?";                                         
$update = $mysqli->prepare($sql);
$update->bind_param("is", $active, $selectedDate);  
$update->execute();

I don’ think I have set the above code correctly as that I am running a CRON job where I have stated that every 28th October (today), it will set the “Active” field to 0.

Problem is that it is setting the active field to “0” for all the rows in my database, even if its after the 28th October this year.

Below is what is suppose to happed:

  • Now the current year is 2012 so when it becomes 28th October (which it is now), any exam which “SessionDate” is before this date should have an “Active” value of “0”, the other Exams remain having an “Active” value of “1”.

  • The CRON will then not do it’s job till next year when it is October 28th again, this time the year will obviously be 2013. The same rules apply any exam which “SessionDate” is before this date should have an “Active” value of “0”, the other Exams remain having an “Active” value of “1”.

  • The CRON will then not do it’s job till the following year when it is October 28th again, this time the year will obviously be 2014. The same rules apply any exam which “SessionDate” is before this date should have an “Active” value of “0”, the other Exams remain having an “Active” value of “1”.

And so on….

So how come all of my database rows are their “Active” fields set to 0 when the CRON is doing it’s bit?

  • 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-06-13T15:09:20+00:00Added an answer on June 13, 2026 at 3:09 pm

    The reason this did not work is because the date structure did not match the date structure from the database.

    In my php script I got it as:

    $selectedDate =  date('d-m-Y', ($createDate));
    

    It should be like this:

    $selectedDate =  date('Y-m-d', ($createDate));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running this command in sql select ID, TASK, CreatedBy,CreateDate from John Results
for example we have date May 12, 2010 <cfset may_12_2010 = CreateDate(2010, 5, 12)>
I need to convert this SQL query to nhibernate declare @i int set @i=2
I am trying to set up a php where that it sets the date
i want set some fields, like updateDate, createDate and deleteDate, for each my entities,
I am trying to convert this SQL statement into LINQ SELECT a.UserId, b.Date, a.Value1
I have the following T-SQL Pivot query. SELECT AccountNumber, EventID, CreateDate, [ITEMBOOK] AS ITEMBOOK,
I have a column called CreateDate (DateTime) in table1 in SQL Server 2008. With
I have the below SQL which works just fine: SELECT Message, CreateDate, AccountId, AlertTypeId
I have a table with CreateDate datetime field default(getdate()) that does not have any

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.