473,811 Members | 3,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php current_date

3 New Member
Hi, I meet some problem in debugging php files.

this is the one running smoothly

Expand|Select|Wrap|Line Numbers
  1. $query = "select account.id as account_id    from account
  2.         where (date(creationdate)=date(current_date-interval '1 days') or account.status='DELETED');
but when I changed the condition to:
Expand|Select|Wrap|Line Numbers
  1. if ($result_array['creationdate'] != date(current_date-interval '1 days'))
  2.     {
  3. //do something
  4. }
[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
Jul 17 '07 #1
5 4657
pbmods
5,821 Recognized Expert Expert
Heya, tao. Welcome to TSDN!

PHP works a little differently than MySQL. Try this instead:
Expand|Select|Wrap|Line Numbers
  1. if ($result_array['creationdate'] != date('+1 day'))
  2.  
Jul 17 '07 #2
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:
Expand|Select|Wrap|Line Numbers
  1. if ($result_array['creationdate'] != date('+1 day'))
  2.  
Jul 18 '07 #3
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...
Jul 18 '07 #4
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
Jul 18 '07 #5
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():
Expand|Select|Wrap|Line Numbers
  1. $yesterday = strtotime('-1 day');
  2.  
Jul 18 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5046
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
2
3614
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
2
8433
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...
11
9838
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,
1
5767
by: sajithamol | last post by:
What is the difference between current_date & sysdate function?
2
4683
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...
1
1352
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');...
2
1238
by: ctje | last post by:
I have a project: Current_Date minus the end of the year.. How can i do this??
2
3417
by: Vikas Jain | last post by:
Hi, please tell me how to subtract month from current_date in postgresql. Thanks in advance. Vikas Jain
0
9605
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,...
0
10393
jinu1996
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...
1
10405
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,...
0
10136
tracyyun
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...
0
9208
agi2029
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...
1
7671
isladogs
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...
1
4342
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
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.