Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    In your short code, try orderby="submit_time" to order them by numeric value instead of by string value.

    Thread Starter danielolaru1991

    (@danielolaru1991)

    Ty for the fast reply. Let me give you more info about what im trying to accomplish. I’m trying to build an appointment system for a clinc with cf7 and list the data on a datatable with the help of cfdb. The fields that patients fill are: name phone email appointmentdate. I need to sort by appointmentdate not by submit time. If date is stored as Y-m-d sortby=”appointmentdate ASC” works great. The problem is if I store dates as d-m-Y sorting messes up and i need dates to be shown as d-m-Y in the table. Ill paste the shortcode i use when i get to work in 1h maybe it helps. Great plugin btw.

    Thread Starter danielolaru1991

    (@danielolaru1991)

    Ok here is the shortcode I’m using:

    [cfdb-datatable form=”myform” hide=”Submitted,Submitted Login,Submitted From” permissionmsg=”true” filter=”strtotime(appointmentdate)>=strtotime(today)” orderby=”appointmentdate ASC” dt_options=”bJQueryUI: true, aaSorting:new Array()”]

    Which works great if the appointment dates are saved as Y-m-d by the cf7+datepicker plugin. Again, the problem is I need the dates to be shown as d-m-Y in the datatable. I tried to submit the dates to database as d-m-Y but the sorting is not working this way. If u need me to be more specific I can come back with some screenshots to make myself more clear. Ty for your time and effort.

    Plugin Author Michael Simpson

    (@msimpson)

    Let’s try creating a hidden field “numdate” that is the numeric form of the data, sort by it, and hide it.

    [cfdb-datatable form=”myform” trans=”numdate=strtotime(appointmentdate)” hide=”Submitted,Submitted Login,Submitted From,numdate” permissionmsg=”true” filter=”strtotime(appointmentdate)>=strtotime(today)” orderby=”numdate ASC” dt_options=”bJQueryUI: true, aaSorting:new Array()”]

    Thread Starter danielolaru1991

    (@danielolaru1991)

    Problem solved. Thanks alot for your time and effort. For others that might encounter similar problems, here is my final working shortcode.

    [cfdb-datatable form=”myform” trans=”numdate=strtotime(appointmentdate)&&appointmentdate=date(‘d-m-Y’,numdate)” hide=”Submitted,Submitted Login,Submitted From,numdate” permissionmsg=”true” class=”stripes” filter=”strtotime(appointmentdate)>=strtotime(today)” orderby=”numdate ASC” dt_options=”bJQueryUI: true, aaSorting:new Array()”]

    If you have problems filtering your dates: “>” = “>” and “<” = “<”

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Order by date field formated d-m-Y’ is closed to new replies.