Jump to content

Sort by time from 2 columns


SkyRanger

Recommended Posts

I am trying to do something that is probably impossible to do but what the heck I am going to ask.

 

Table: posts

 

column 1:  opdate

column 2:  odate

 

 

$query = "SELECT * FROM office ORDER BY `opdate`, `odate` DESC $max";

 

What I am trying to do is for example:

 

opdates

 

1) 23 Apr 07 08:34

2) 23 Apr 07 10:12

3) 23 Apr 07 13:49

4) 23 Apr 07 09:28

 

odates

 

1) 22 Apr 07 23:08

2) 22 Apr 07 22:15

3) 23 Apr 07 08:58

 

 

The output shows as

 

subject  odate  odates

 

sub1        1        1

sub2        2        2

sub3        3

sub4        4        3

 

What I am trying to do is sort out the dates to put the newest time either opdates or odates on top and down.  Have it sort the times from newest to oldest comparing the dates and times from the 2 tables

 

So if

sub1 odate = 23 Apr 07 14:58

sub2 odate = 23 Apr 07 11:12

sub3 opdate = 23 Apr 07 12:01

 

It will sort them sub1, sub3, sub2

 

Is this possible?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/48330-sort-by-time-from-2-columns/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.