473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

php current_date

3
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_ENCAPSED_STRING


can anyone throw some idea??

Thank you
Jul 17 '07 #1
5 4636
pbmods
5,821 Expert 4TB
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
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 Expert 1GB
You are trying to compare a DATE field to a string [PHP]if ($result_array['creationdate'] != date(current_date-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
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_date-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 Expert 4TB
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
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...
2
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
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...
11
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...
1
by: sajithamol | last post by:
What is the difference between current_date & sysdate function?
2
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...
1
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...
2
by: ctje | last post by:
I have a project: Current_Date minus the end of the year.. How can i do this??
2
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.