{docurl}
I would like, filter by date. Is this possible?
This is possible, albeit a bit difficult to do.
Many people incorrectly attempt something like the following:
(this code will NOT work)
((%orderdate% GE '1/1/2006') AND (%orderdate% LE '2/15/2006'))
This format will not work due to the way Miva Script handles strings (and the way the date is stored). Instead you'll have to separate out each of the "month", "date" and "year" and make separate comparision such as:
((day_of_month GE 1) AND (day_of_month LE 15)) AND
((month GE 1) AND (month LE 2)) AND
((year GE 2005) AND (year LE 2006))
In addition, the token %orderdate% will display a text string of the date and isn't properly formatted for making accurate comparisons.
So the filter will have to use the raw date (the seconds since 1/1/1970) which is stored in the database field Orders.d.date. Throw in some miva script time functions (which derive the day of the month, the month, and the year from the raw time data) and you have a solution.
The correct syntax for that filter would be:
((time_t_dayofmonth(Orders.d.date, timezone()) GE '1') AND (time_t_dayofmonth(Orders.d.date, timezone()) LE '15')) AND
((time_t_month(Orders.d.date,timezone()) GE '1') AND (time_t_month(Orders.d.date,timezone()) LE '2')) AND
((time_t_year(Orders.d.date, timezone()) GE '2005') AND (time_t_year(Orders.d.date, timezone()) lE '2006'))
In instances where a particular day,month, or year isn't in a range it can be simplified using EQ (equal) but it isn't necessary:
((time_t_dayofmonth(Orders.d.date, timezone()) GE '1') AND (time_t_dayofmonth(Orders.d.date, timezone()) LE '15')) AND
((time_t_month(Orders.d.date,timezone()) GE '1') AND (time_t_month(Orders.d.date,timezone()) LE '2')) AND
((time_t_year(Orders.d.date, timezone()) GE '2005') AND (time_t_year(Orders.d.date, timezone()) lE '2005'))
can be simplified to:
((time_t_dayofmonth(Orders.d.date, timezone()) GE '1') AND (time_t_dayofmonth(Orders.d.date, timezone()) LE '15')) AND
((time_t_month(Orders.d.date,timezone()) GE '1') AND (time_t_month(Orders.d.date,timezone()) LE '2')) AND
((time_t_year(Orders.d.date, timezone()) EQ '2005'))
would find orders with a date from 1/1/2005 to 2/15/2005
Last update: 2007-11-08 14:00
Author: Luis
Revision: 1.2
You cannot comment on this entry
Records in this category
- "order filter" and "item filter" Field Uses
- Using "Order Filter" to Limit the Export to a Particular Shipping Method
- What tokens can I use to export data about coupons, gift certificates, and other "charges"?
- The program I want to import the data into requires that I have some text at the end of the exported file for each order (i.e. after the products). How can I do that?
- Is there any way to remove characters like hard-returns and quotation marks from the exported data?
- I would like to base the exported file name on the date or the batch name. Can I do this?
- Can I export line breaks and carriage returns into the file?
- I would like, filter by date. Is this possible?














