Page 1 of 1

Shortcut by URL: All records for datetime between for today

Posted: Tue Sep 10, 2013 11:38 pm
by mpol_ch

Hallo

How can get all records which have today's date by URL?
My field has datetime. I want all records between yesterday and tomorrow.

thanks
mpol_ch


Re: Shortcut by URL: All records for datetime between for to

Posted: Wed Sep 11, 2013 9:47 am
by danielc

You can run the extended search to get the url using "between" for your field.

Here is example using demo project, orders: table, field: RequiredDate, date-format: YYYY/mm/dd:
orderslist.php?cmd=search&t=orders&z_RequiredDate=BETWEEN&x_RequiredDate=1996%2F08%2F01&y_RequiredDate=1996%2F08%2F02&psearch=&psearchtype=%3D

You can replace with your table, your field and search date, then you can get your url string to search for your records between your required date.


Re: Shortcut by URL: All records for datetime between for to

Posted: Wed Sep 11, 2013 9:57 am
by mobhar

The best practice for displaying the URL that contains the range of datetime is by using the Advanced Search which have the search criteria using that datetime field from <yesterday> to <today>.

In order to use the dynamic date automatically, then you can define the default value for that datetime field by using "Page_DataRendering" server event that belongs to the "Search Page".

For example, assuming that the field name is "MyDateTimeField", then put the following code into "Page_DataRendering" server event:

if ($this->MyDateTimeField->EditValue == "") {
$this->MyDateTimeField->EditValue = date('Y-m-d', strtotime("-1 days")). " 00:00:00"; // yesterday
}

if ($this->MyDateTimeField->EditValue2 == "") {
$this->MyDateTimeField->EditValue2 = date('Y-m-d'). " 23:59:59"; // today
}

You can actually remove the time above if unneccessary, for example, if you only want to display the date.


Re: Shortcut by URL: All records for datetime between for to

Posted: Wed Sep 11, 2013 3:49 pm
by mpol_ch

Hello danielc and mobhar

thanks a lot for your replies. But I still do not see what I should do? Below you see my URL. I want replace the x_Datum with PHP expression so that I can get back allways the record of today. I will put this URL in Menu with titel "Calls Today".

URL: mpol.ch/mpol/mpolcallslist.php?x_Datum=10.09.2013+00%3A00&y_Datum=11.09.2013+00%3A00&z_Datum=BETWEEN&cmd=search

thanks again.
mpol_ch


Re: Shortcut by URL: All records for datetime between for to

Posted: Wed Sep 11, 2013 4:07 pm
by digitalphotoworld

Try this:

$heute = date("d.m.Y");
$morgen = date("d.m.Y",strtotime("+1 day"));
$url = "mpol.ch/mpol/mpolcallslist.php?x_Datum=$heute+00%3A00&y_Datum=$morgen+00%3A00&z_Datum=BETWEEN&cmd=search";


Re: Shortcut by URL: All records for datetime between for to

Posted: Wed Sep 11, 2013 5:17 pm
by mpol_ch

Hello thanks a lot for all the responses.
I solved my problem as below:

I entered date("d.m.Y") and date("d.m.Y",strtotime("+1 day")) in advanced search. I enabled the Extended search and the search operator is BETWEEN.
I generated the the files and renamed the file with "_today" it will be called mpolcalls_todaylist.ph .

Then I do an Menu record to this file.

Thanks four your replies.

mpol_ch