Jump to content

Recommended Posts

I have a timestamp column, how can I get the timestamp with the closest time to the current time?

 

Example:

 

Now: 2008-10-31 15:23:00

 

In database:

2008-10-30 14:25:00

2008-10-29 08:54:00

2008-10-31 14:32:00

2008-10-29 22:10:00

 

The closest one to Now would be the 3rd one.

Link to comment
https://forums.phpfreaks.com/topic/130938-newest-date/
Share on other sites

Then how would yo integrade it into this query? It needs to be the newest from either the table: topics or replies.

 

SELECT c.`category`,
c.id AS 'cid',
b.order,
b.`title` AS 'title',
b.`description` AS 'description',
b.id 'bid',
COUNT(t.id) AS 'topicCount',
COUNT(r.id) AS 'postCount'
FROM `boards` b
LEFT JOIN topics t ON(t.`boardID` = b.id)
LEFT JOIN replies r ON(r.`topic_id` = t.id)
LEFT JOIN categories c ON(b.`group` = c.id)
GROUP BY b.`id`
ORDER BY
c.`order` ASC, b.`group` ASC, c.`order` ASC

Link to comment
https://forums.phpfreaks.com/topic/130938-newest-date/#findComment-679738
Share on other sites

TLG, what are you trying to accomplish in relation to the forum you're building?

 

Is this to pull the title of the last post to display in the "Last post info" area?

 

Also, it would help me if you gave me a data dump (not the schema, but actual data export as well) and tell me what columns to display and what conditions). .. mainly data to work with.

 

I have a feeling it will be an additional column in that query that's something like: select max(post_date) from replies where topic id in topic.id or w/e

Link to comment
https://forums.phpfreaks.com/topic/130938-newest-date/#findComment-679769
Share on other sites

I just want to grab what the last post date of the item is, such as in the forum...

 

"on Today at 12:24:24 PM"

 

That shows the date and time of the last post or topic. I need to grab that date.

 

I have tried a MAX, and it just displays as "1"... maybe I was doing it wrong.

Link to comment
https://forums.phpfreaks.com/topic/130938-newest-date/#findComment-679775
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.