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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:58:19+00:00 2026-06-18T03:58:19+00:00

I am trying to retrieve the month value of a calculation : SELECT strftime(‘%m’,

  • 0

I am trying to retrieve the month value of a calculation :

SELECT strftime('%m', 'now') - strftime('%m', e.date) AS something FROM ...

But here are the results I get and what I really want :

NOW - 2012-02-03 = 0 // want 11
NOW - 2012-11-02 = -9 // want 3
NOW - 2012-02-02 = 0 // want 12
NOW - 2012-01-02 = 1 // want 13

As I can see I can almost get the right values by doing sqlResult + 12 (except for first example) but is there a way to achieve this directly in the SQL statement and to get exact values in every case ?

EDIT : Finally here is the solution

SELECT CAST ((julianday('now') - julianday(e.date_retour)) / 30 AS integer) AS something
  • 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-18T03:58:20+00:00Added an answer on June 18, 2026 at 3:58 am

    You are not really looking at difference between two months but, considering their years as well.

    So you need to do like this:

    SQLite (SQL.js) Demo

    SELECT round((julianday(Date('now')) - 
            julianday(Dates))/30) as MonthsDiff
    from demo;
    
    
    | MonthsDiff |
    --------------
    |       11.0 |
    |        2.0 |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I got a problem here. I'm trying to retrieve the date from the
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I'm trying to retrieve the attribute value from an xsl:param and use it in
I'm trying to filter a date retrieved from a .csv file, but no combination
I am trying to retrieve the date of birth from users once they submit
I'm trying to retrieve the month using date . $year= 2012; $mon = date(
I am trying to retrieve results from this query, but it is not fetching
Im trying to retrieve all users from a domain, but I get an error..
i am trying to retrieve date from Mysql db to my html form in
I'm trying to retrieve all rows inserted during a specific month. SELECT dbo.Post.UserId, dbo.Post.Tags,

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.