This topic is locked
[SOLVED]

 Unable to list records using specific date.

10/30/2013 2:52:53 PM
PHPRunner General questions
S
suryateja619 author

Hi All,
I want list records of today's date. So, In my events in list page before sql query i am using the following code.



$dat = date('Y-m-d');

$strWhereClause = "date_received = '$dat'";


But when i want to list other day records using search option it lists records on the current day itself due to above query. Any suggestions on how to approach this problem.

C
copper21 10/30/2013

You are not giving $dat a value and the $strWhereClause needs to be like:
$dat = date('Y-m-d', strtotime(now()));
$strWhereClause = whereAdd($strWhereClause, "date_received = '$dat'");
Or better yet, just do it in your SQL query on the Query Section:
Select ...

From YourTable

WHERE date_received = CONVERT(varchar(10), GETDATE(), 111)

S
suryateja619 author 10/30/2013

Hi Brian,
I was successfully able to list records but i was unable to list any other day record when i was search through advanced search. When i was selecting previous day to list them there was an error such as no records found.



You are not giving $dat a value and the $strWhereClause needs to be like:
$dat = date('Y-m-d', strtotime(now()));
$strWhereClause = whereAdd($strWhereClause, "date_received = '$dat'");
Or better yet, just do it in your SQL query on the Query Section:
Select ...

From YourTable

WHERE date_received = CONVERT(varchar(10), GETDATE(), 111)

C
copper21 10/30/2013

If you want access to all records, then you will use neither of those. If you just want today's records, then just use the search page and in the date_received field, use "equals" and then put today's date in.."10/30/2013"
Not sure if that is what you are trying to do. If you want to put all of the date_received records together, use ORDER BY date_received DESC after the "FROM" or "WHERE" in your query.