Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 23/11/2024 Black Friday 2024

    BIG SALE, 30% discount for all our extensions. Use BF24 coupon code. Hurry up the discount is valid till 3 December.

  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

Time and Day Formatting / Sorting
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Time and Day Formatting / Sorting
#30629
Time and Day Formatting / Sorting 12 Years, 3 Months ago Karma: 0
I love the capability of Ari Data Tables -but I'm searching for the best way to handle a challenge. I'd like to publish a weekly schedule, and have it sort properly. Sample data might be something like this:

Monday | 4th Street | 5:00 PM | Zumba
Friday ] 34th Street | 6:00 PM | Body Sculpt

Currently, I'm using a CSV file for the source - because it's easiest for getting formats from person in charge of the schedule. However, this produces some poor sorting results because day and time are coming in as text.

Consequently, Friday comes before Monday, and 9 AM comes after 5 PM. Here's the link to the testing page:

Link is here[/url]

I'm looking for the best / easiest way to have items sort properly.
The administrator has disabled public write access.
 
#30630
Re:Time and Day Formatting / Sorting 12 Years, 3 Months ago Karma: 760
Hello,

It requires custom modification of the extension.

Regards,
ARI Soft
The administrator has disabled public write access.
 
#30840
Re:Time and Day Formatting / Sorting 12 Years, 3 Months ago Karma: 2
Create a helper column in the XLS file that simply expresses the date as a number, and then sort on that column.
The administrator has disabled public write access.
 
#30882
Re:Time and Day Formatting / Sorting 12 Years, 3 Months ago Karma: 2
gobodyworks wrote:
I love the capability of Ari Data Tables -but I'm searching for the best way to handle a challenge. I'd like to publish a weekly schedule, and have it sort properly. Sample data might be something like this:

Monday | 4th Street | 5:00 PM | Zumba
Friday ] 34th Street | 6:00 PM | Body Sculpt

Currently, I'm using a CSV file for the source - because it's easiest for getting formats from person in charge of the schedule. However, this produces some poor sorting results because day and time are coming in as text.

Consequently, Friday comes before Monday, and 9 AM comes after 5 PM. Here's the link to the testing page:

Link is here[/url]

I'm looking for the best / easiest way to have items sort properly.


In your output chart, do you want the user to sort by whichever column they desire, or is the output fixed, sorted by a column that you have pre-determined?
The administrator has disabled public write access.
 
#30884
Re:Time and Day Formatting / Sorting 12 Years, 3 Months ago Karma: 2
MySQL does have a date format function:

dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_date-format

The smallest way to uniquely express a date is %j%Y. To add the time, append %T.


It would like ugly, but could you have your data looking like this:

SELECT CONCAT('[', DATE_FORMAT(Date, '%Y%j'), '] ', DATE_FORMAT(Date, '%W, %M %D, %Y')) AS Date
FROM Table;


The output would be:

[2012200] Thursday, July 19th, 2012
[2012201] Friday, July 20th, 2012

But this would show the unnecessary data between the [ and ]. What if you right-justified the column and limited the width of the column, it might truncate that portion off?
The administrator has disabled public write access.
 
#30906
Re:Time and Day Formatting / Sorting 12 Years, 3 Months ago Karma: 2
Hello gobodyworks,

I solved your problem.

The key to displaying dates/times in chronological order is to sort by a field that represents the date and/or time as a duration since a fixed date/time.

I looked at the MySQL date format features and they contain the %-values. The %j element was very useful - it represents a date as the number of days since Jan 1 of that year. This is aka day-of-the-year ("doty").

So I created a string that chronologically orders each date/time: the year, followed by "doty", then the time in 24-hour format. This format string is short - making it easy to follow: %Y%j%T. July 1st, 2012 at 12 noon would be:

%Y %j %T
201218212:00:00

The next thing to do is to prepend this string to the real date/time string.

If I use the additional format string of "%W, %M %D, %Y at %r" So you're left with:

[201218212:00:00] Sunday, July 1st, 2012 at 12:00:00

Now, use the HTML tag attribute called "hidden". This keeps text present, but not visible.

An example is: <span hidden="hidden">Text you won't see.</span>

<span hidden="hidden">[201218212:00:00]</span>Sunday, July 1st, 2012 at 12:00:00

When you click sort, it will sort by the data at the beginning of the field until a difference is found. Well, the differences are contained in the text inside the [ and ]. But that text isn't displayed, because you likely don't wish to show it. lol

I made an example page on my website: www.halscrib.com/index.php/hidden/date-test

The returned data is every hour of every day from June 1, 2012 to Dec 31, 2012. You can see how the data is all properly sorted. I also included a second column, which is the sort key itself - the text inside the <span hidden="hidden"> </span> tags. This allows you to see what the table is sorting on.

The full SQL command is:

Code:

SELECT
    CONCAT('<span hidden="hidden">[', DATE_FORMAT(DateTime, '%Y%j%T'), '] </span>', DATE_FORMAT(DateTime, '%W, %M %D, %Y  at  %r')) AS Tournament,

    CONCAT('[', DATE_FORMAT(DateTime, '%Y%j%T'), ']') AS SortKey

    FROM Tournaments;





Hopefully that works for you too.
Last Edit: 2012/08/25 11:28 By JugglingReferee.
The administrator has disabled public write access.
 
Go to topPage: 1