Miva Merchant 4 Module FAQs » Generic Order Export (BROK_GENEXPORT)


{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

Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 0 out of 5 (0 Votes )

completely useless 1 2 3 4 5 most valuable

You cannot comment on this entry