Posted by tumbledown100 on November 28, 2012 at 8:36am
Hi,
I am trying to sort a view of nodes using a text field with the time of day using the 12 hour clock as the sort criteria. Each node has one text field with a particular time in it. For example,
7.30am
10am
3pm
7.15pm
etc.
The trouble is, it doesn't sort them into any kind of order I can make sense of - let alone into chronological order as above.
Does anyone know if this is possible? How to achieve it?
Thanks for your help,
Comments
Actually on closer
Actually on closer examination, it nearly gives me what I want.
Here's an example:
1.15pm
10.30am
10am
12.30pm
1pm
4.30pm
5.30pm
6.15pm
6pm
7.30pm
7.45pm
7am
7pm
7pm
8pm
8pm
It is not far off being correct, but I can't work out why, for example, it is putting 1.15pm before 10am - or what I can do to correct it.
It's sorting by text. When
It's sorting by text. When sorting text, a period (apparently) comes before the zero. So the '1' is found as the first character (both values same), and the second characters are a period and a zero, and since the period alphabetically comes before the zero, the one with the period comes first.
Honestly, I don't think you can sort on this field, using views or otherwise, as sorting numerically will also give you a strange order.
Jaypan We build websites
Thanks a lot. It is obvious
Thanks a lot. It is obvious now you've pointed it out.
And slightly depressing. I've got 1000+ existing nodes that have to be sorted by time. Apart from adding a new Date module (or similar) field and manually inputting the data, I can't think where to go from here. Any thoughts gratefully received.
Try adding a new field to
Try adding a new field to your content type (numeric) and add that to your view, sort by it the new field and leave it hidden. Use sql to put in the desired values.