tao 3
New Member
Hi, I meet some problem in debugging php files.
this is the one running smoothly - $query = "select account.id as account_id from account
-
where (date(creationdate)=date(current_date-interval '1 days') or account.status='DELETED');
but when I changed the condition to: - if ($result_array['creationdate'] != date(current_date-interval '1 days'))
-
{
-
//do something
-
}
[Please use CODE tags when posting source code. Thanks! --pbmods]
there is parse error for '1 days'
parse error, unexpected T_CONSTANT_ENCA PSED_STRING
can anyone throw some idea??
Thank you
5 4657 pbmods 5,821
Recognized Expert Expert
Heya, tao. Welcome to TSDN!
PHP works a little differently than MySQL. Try this instead: -
if ($result_array['creationdate'] != date('+1 day'))
-
tao 3
New Member
still doesn't work...
can someone help again?
Heya, tao. Welcome to TSDN!
PHP works a little differently than MySQL. Try this instead: -
if ($result_array['creationdate'] != date('+1 day'))
-
code green 1,726
Recognized Expert Top Contributor
You are trying to compare a DATE field to a string [PHP]if ($result_array['creationdate'] != date(current_da te-interval '1 days'))[/PHP] At the same time you are trying to pass a mathematical result and a string with no concatenation to date().
What is it you are trying to achive? The following is not very helpful
still doesn't work...
tao 3
New Member
the data type of current_date is DATE, so I am not comparing a DATE to a string.....
I am trying to get the value of yesterday by (current_date-interval '1 days') in php.
You are trying to compare a DATE field to a string [PHP]if ($result_array['creationdate'] != date(current_da te-interval '1 days'))[/PHP] At the same time you are trying to pass a mathematical result and a string with no concatenation to date().
What is it you are trying to achive? The following is not very helpful
pbmods 5,821
Recognized Expert Expert
Heya, tao.
the data type of current_date is DATE, so I am not comparing a DATE to a string.....
I am trying to get the value of yesterday by (current_date-interval '1 days') in php.
MySQL may store the value as a date, but it fetches it as a string. To compare it to another date, you must first convert it into a timestamp by using strtotime().
To get yesterday's date, you will also need to use strtotime(): -
$yesterday = strtotime('-1 day');
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: toedipper |
last post by:
Hello,
MYsql and PHP
If I want to extract data with todays date then it's 'where blab blah =
current_date()'
For yesterday it's 'where blah blah = current_date()-1'
But can anyone tell me how to extract all data from the start of the
|
by: toedipper |
last post by:
Hello,
PHP and mysql
I have the following select statement whch gives me a count for
downloads for previous day.
SELECT
COUNT(swid)
FROM
|
by: David Garamond |
last post by:
I was thinking on how one would design an optimal (performance-wise)
database of large number of schedules with crontab-like semantic. There
will potentially be hundreds of thousands or even millions of "crontab"
entries, and there will be a query run once every minute to determine
which entries are to be run for that minute. The primary goal is, of
course, for the query to run as fast as possible.
My first stab is, straightforward...
|
by: sayamishiraj |
last post by:
i am using vb 6 and postgresql as the back end. when running the function in the vb , it shows the error message of odbc call failed. but when i run the same function in the postgresql then it runs easily. can anyone suggest how can i increase the execution time in the odbc since the database is too huge,
|
by: sajithamol |
last post by:
What is the difference between current_date & sysdate function?
| |
by: apollock |
last post by:
Our application is having an issue where a query in a stored procedure periodically gets a bad plan with a Lazy Spool Operator that changes the query execution time from 5ms to 900ms and kills our CPU. We are running x64 SQL 2005 SP2 on Windows 2003 SP2.
We thought it might be parameter sniffing that was causing the bad plan, so we re-wrote the query to disable parameter sniffing. Unfortunately, that made the problem worse as we always...
|
by: matthewroth |
last post by:
I have searched high and low and am stumped on this. The below code is a checklist form for work. there are 2 shifts 7 days a week and it displays the checklist items for each shift. something i did not plan on was a bi-weekly task. (dumb oversight, I know) Can anyone point me in the right direction to add an item that would only occur every 2 weeks. thanks in advance
<?
include_once('./sql_connect.php');
include_once('./links.php');...
|
by: ctje |
last post by:
I have a project: Current_Date minus the end of the year..
How can i do this??
|
by: Vikas Jain |
last post by:
Hi,
please tell me how to subtract month from current_date in postgresql.
Thanks in advance.
Vikas Jain
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |