Title: Changing sorting on csv export
Last modified: December 2, 2019

---

# Changing sorting on csv export

 *  Resolved [pierremare](https://wordpress.org/support/users/pierremare/)
 * (@pierremare)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/)
 * Hi, The export to CSV function works great. Does anyone know of a way to export
   the data so that it is sorted by event/activity Start date? I would really like
   this toi be the default as it will be easier to look at on a mobile phone where
   it opens up without ability to apply manual filters on the heading fields. Thanks
   in advance for any help!

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [yoancutillas](https://wordpress.org/support/users/yoancutillas/)
 * (@yoancutillas)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12196623)
 * You can do that
 * **without code:**
    Do not click on “Export”, instead – copy the export url, –
   paste it in a new tab of your browser – add `&order_by=event_start` at the end
   of the URL – Load the page, it will download your csv file
 * **with code:**
    Add this code in your child theme functions.php:
 *     ```
       function my_theme_export_bookings_attributes( $filters ) {
       	$filters[ 'order_by' ] = array( 'event_start' );
       	$filters[ 'order' ] = 'desc';
       	return $filters;
       }
       add_filter( 'bookacti_export_bookings_attributes', 'my_theme_export_bookings_attributes', 100, 1 );
       ```
   
 * Note that the whole list will be sorted, so if you want to export bookings only
   during a specific frame of time, fill the “Date” filter before exporting (no 
   need to apply filters).
 *  Thread Starter [pierremare](https://wordpress.org/support/users/pierremare/)
 * (@pierremare)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12196693)
 * You are absolutely amazing, thank you so much this “small” thing has just moved
   a mountain of a process out of the way for me with a client. May you become so
   rich you do not know what to do with all the money 🙂
 * Thanks again.
 * Works perfectly.
 *  Plugin Author [yoancutillas](https://wordpress.org/support/users/yoancutillas/)
 * (@yoancutillas)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12196985)
 * Ah ah! May Santa browse this forum 🙂
 * Great, thank you for your feedback,
    Moreover, in the next version (1.7.12), 
   the exported bookings will keep the current booking list sorting by default, 
   so you will be able to sort them using the UI.
 *  Thread Starter [pierremare](https://wordpress.org/support/users/pierremare/)
 * (@pierremare)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12198055)
 * One more thing, is if possible to change the format of the date in the url csv
   export to say Mon, Tues, Wed? Or change the date format?
 *  Thread Starter [pierremare](https://wordpress.org/support/users/pierremare/)
 * (@pierremare)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12199198)
 * The client would basically like the date to be exported to show the name of the
   DAY of the week. I don’t think that is possible? At least I think the date format
   can refer to the name of the MONTH such as “30-June 2008” but nit the DAY. Do
   you agree?
 *  Plugin Author [yoancutillas](https://wordpress.org/support/users/yoancutillas/)
 * (@yoancutillas)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12200079)
 * The csv format isn’t meant to be read by humans, that’s why raw data are exported,
   so you can manipulate them easier later in the app where they are imported (MS
   Excel, Google Sheets, etc…)
    Those apps will be able to read those date, recognize
   them as such, and automatically convert them in any user-friendly format, because
   they are in ISO format.
 * But it is possible by code:
    Hook: `'bookacti_booking_export_columns_content'`
   [wp-content\plugins\booking-activities\functions line 1206](https://github.com/bookingactivities/booking-activities/blob/1.7.11/functions/functions-bookings.php#L1205)
 *     ```
       // Format exported bookings data
       function my_theme_format_exported_bookings_data( $booking_item, $booking, $group, $user, $filters, $columns ) {
       	$booking_item[ 'start_date' ] = bookacti_format_datetime( $booking_item[ 'start_date' ], 'D d-F Y' );
       	$booking_item[ 'end_date' ] = bookacti_format_datetime( $booking_item[ 'end_date' ], 'D d-F Y' );
       	return $booking_item;
       }
       add_filter( 'bookacti_booking_export_columns_content', 'my_theme_format_exported_bookings_data', 100, 6 );
       ```
   
 * Where ‘D d-F Y’ is the date format ([docs](https://www.php.net/manual/fr/function.date.php)).
 *  Thread Starter [pierremare](https://wordpress.org/support/users/pierremare/)
 * (@pierremare)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12203009)
 * You really are a genius! thanks. In this particular use case the client is simply
   using the export url to quickly view an activities bookings for the day on their
   mobile phone with least hassle, so they arent opening in another program but 
   viewing the CSV straight in their phone browser – > your explanation makes perfect
   sense.
 * Last last question promise. On the front end when viewing the calendar in “Week
   view” the date displays as “Wed 12/11” – this means of course 11th of December
   but is American format.
 * I would just like to swap the month and day around so that the 11th of Dec is
   displayed as “Wed 11/12” instead of “Wed 12/11” – I have tried to change this
   in the plugin settings as well as wordpress settings but not managed to get it
   right. Are you able to assist?
    -  This reply was modified 6 years, 6 months ago by [pierremare](https://wordpress.org/support/users/pierremare/).
 *  Plugin Author [yoancutillas](https://wordpress.org/support/users/yoancutillas/)
 * (@yoancutillas)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12207782)
 * You are welcome 🙂
 * The date format in the calendar is determined by your site locale in Settings
   > General > “Site language” option.
 * If you set it to “English (UK)” the date format will be as desired.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Changing sorting on csv export’ is closed to new replies.

 * ![](https://ps.w.org/booking-activities/assets/icon-256x256.png?rev=1709970)
 * [Booking Activities](https://wordpress.org/plugins/booking-activities/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/booking-activities/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/booking-activities/)
 * [Active Topics](https://wordpress.org/support/plugin/booking-activities/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/booking-activities/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/booking-activities/reviews/)

## Tags

 * [export](https://wordpress.org/support/topic-tag/export/)
 * [sort order](https://wordpress.org/support/topic-tag/sort-order/)

 * 8 replies
 * 2 participants
 * Last reply from: [yoancutillas](https://wordpress.org/support/users/yoancutillas/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/changing-sorting-on-csv-export/#post-12207782)
 * Status: resolved