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 9242897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:41:07+00:00 2026-06-18T08:41:07+00:00

I wrote this query and it is working fine, except in the month of

  • 0

I wrote this query and it is working fine, except in the month of FEB! for some reason because FEB has 28 days by using the INTERVAL 1 MONTH function it reads back into JAN also. and it should only read from start of FEB to END of FEB!

SELECT SUM(IF((`date` BETWEEN DATE_SUB('2013-02-28', INTERVAL 1 MONTH) AND '2013-02-28'), earnings, "null")) AS Rev0 
FROM table
  • 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-18T08:41:09+00:00Added an answer on June 18, 2026 at 8:41 am

    Given any date, you can use this to get the first day of the month:

    DATE_SUB('2013-02-28', INTERVAL DAY('2013-02-28')-1 DAY)
    

    or also this:

    CAST(DATE_FORMAT('2013-02-28' ,'%Y-%m-01') as DATE)
    

    and for the last day, there’s a function already defined:

    LAST_DAY('2013-02-28')
    

    your query would then become:

    SELECT
      SUM(IF((`date` BETWEEN DATE_SUB('2013-02-28', INTERVAL DAY('2013-02-28')-1 DAY)
              AND LAST_DAY('2013-02-28')), earnings, "null")) AS Rev0 
    FROM table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query below, its working fine, and I'm getting what I need.
This query is working fine. It gives a count of contest entrants for whom
I have a list property tag_list = db.StringListProperty() This has been working fine so
I have this query (I didn't write) that was working fine for a client
I wrote this query: INSERT INTO KeysTable (KeyText, Id) SELECT KeyText as BKT, KeysTable.ID
I wrote a query in this format.. Select * INTO #xyz FROM () which
Normally when I want to query large result set using Mysql I write this
I have this SQL statement which is working fine, but it doesn't satisfy my
Wrote a custom backend component, been working fine. A subset of users were only
I wrote my own mvc for php, and it seems to be working fine

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.