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

  • SEARCH
  • Home
  • 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 8679211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:54:52+00:00 2026-06-12T20:54:52+00:00

i have a table of adds in my database and i define a field

  • 0

i have a table of adds in my database and i define a field date with each record which has a type of varchar and srores date in date format. i insert value in date field by using now() function and my date field has value in format

2012-10-07 14:00:54

i want to fetch the records matching by date of today,yesterday,last week and last month but i dont know how to do this. i searched on google alot and i tried many functions but its not working i run the following queries

select * from adds where date(date_sub(now(), interval 0 day))
   select * from adds where date(date_sub(now(), interval 1 day))
   select * from adds where date(date_sub(now(), interval 7 day))
   select * from adds where date(date_sub(now(), interval 31 day))

all these are not working and i also tried

select * from adds where date=curdate()
  select * from adds where date=current_date()

please guide me how can i fetch records.
i am using localhost server xampp win32 1.7.7

  • 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-12T20:54:53+00:00Added an answer on June 12, 2026 at 8:54 pm

    i want to fetch the records matching by date of today,yesterday,last
    week and last month but i dont know how to do this.

    Then you need to SELECT those records where the date is between the bounds:

    SELECT * FROM adds WHERE `date`
          BETWEEN
              DATE(DATE_SUB(NOW(), INTERVAL 7 DAY))
          AND DATE(DATE_SUB(NOW(), INTERVAL 0 DAY))
    ;
    

    The above ought to give you last week, ending at today’s beginning at 00:00.

    Note: the above works if the varchar date syntax is the same as MySQL. If it is not, you need to specifically instruct MySQL as how to parse it:

      WHERE STR_TO_DATE(`date`,'%Y:%d:%m %H:%i:%s') BETWEEN..
    

    See date_format() for the date format syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table which contanis a field name Province bits and it
I have a table where on a single record update, a trigger adds a
So i have a table that is built dynamically that adds rows for each
I have a table called jobs in a MySQL database. One user adds data
I have a script which runs through a database table and downloads a file
I have a DataGridView which I have bound to a single ODBC database table
I have a query in VBA that Adds a few columns to a table.
I have table in which I am inserting rows for employee but next time
I have table with 300 000 records (MyISAM). I get record from this table
I'm currently coding a product which will have only one database but will host

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.