Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8832401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:31:13+00:00 2026-06-14T08:31:13+00:00

I am retrieving data from a table and show the total SUM of entries.

  • 0

I am retrieving data from a table and show the total SUM of entries. What I want to do is to show the total SUM of entries made on today’s date, yesterday and this month. The table is using the unix timestamp format (e.g. 1351771856 for example).

Currently I am using this line to show todays results:

AND comment_date > UNIX_TIMESTAMP() - 24 * 3600";

but that gives me just the entries for the last 24 hours.

Example: So let’s say its Friday, 17:00 PM – it gives me the count from Thursday 17:00 PM to Friday 17:00 PM

What I want is to get the results for

  • Thursday 00:00:00 – 23:59:59 (yesterday in this case)
  • the results for today (00:00:00 – 23:59:59)
  • and last week, results that start on Monday, 00:00:00 until “today” (in this case Friday).

I couldn’t find a way in the MySQL documentation to achieve this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:31:14+00:00Added an answer on June 14, 2026 at 8:31 am

    This mysql code should work for you:

    // Today
    AND DATE(from_unixtime(comment_date)) = CURRENT_DATE
    
    // Yesterday
    AND DATE(from_unixtime(comment_date)) =  DATE_SUB(CURRENT_DATE,INTERVAL 1 DAY)
    
    // This week
    AND YEARWEEK(from_unixtime(comment_date), 1) =  YEARWEEK(CURRENT_DATE, 1)
    
    // This month
    AND YEAR(from_unixtime(comment_date)) = YEAR(CURRENT_DATE)
    AND MONTH(from_unixtime(comment_date)) = MONTH(CURRENT_DATE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am retrieving data from table but instead of all row, I want 20
I'm retrieving data from a MySQL table and displaying it on a webpage using
Currently, I'm retrieving some data from a MySQL database table, but the problem is
I have written this query for retrieving data from mysql as below select FeedbackCode,EMailID,FeedbackDetail,
I'm retrieving data from a mysql table column and placing it into a textarea.
When we are retrieving data from database, we use something like this SELECT *
<table class=table table-striped> <thead> <tr> <th>Select</th> <th>From</th> <th>Subject</th> <th>Date</th> </tr> </thead> <tbody> <?php //show
I am retrieving data from a SQL table so I can display the result
I am retrieving some data from a table in mysql. The values are stored
I have problem today about retrieving data from SQLite. Here is my coding public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.