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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:40:25+00:00 2026-06-11T11:40:25+00:00

I have a table with a date column where date is stored in this

  • 0

I have a table with a date column where date is stored in this format:

2012-08-01 16:39:17.601455+0530

How do I group or group_and_count on this column by month?

  • 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-11T11:40:26+00:00Added an answer on June 11, 2026 at 11:40 am

    Your biggest problem is that SQLite won’t directly recognize your dates as dates.

    CREATE TABLE YOURTABLE (DateColumn date);
    INSERT INTO "YOURTABLE" VALUES('2012-01-01');
    INSERT INTO "YOURTABLE" VALUES('2012-08-01 16:39:17.601455+0530');
    

    If you try to use strftime() to get the month . . .

    sqlite> select strftime('%m', DateColumn) from yourtable;
    01
    

    . . . it picks up the month from the first row, but not from the second.

    If you can reformat your existing data as valid timestamps (as far a SQLite is concerned), you can use this relatively simple query to group by year and month. (You almost certainly don’t want to group by month alone.)

    select strftime('%Y-%m', DateColumn) yr_mon, count(*) num_dates 
    from yourtable 
    group by yr_mon;
    

    If you can’t do that, you’ll need to do some string parsing. Here’s the simplest expression of this idea.

    select substr(DateColumn, 1, 7) yr_mon, count(*) num_dates 
    from yourtable 
    group by yr_mon;
    

    But that might not quite work for you. Since you have timezone information, it’s sure to change the month for some values. To get a fully general solution, I think you’ll need to correct for timezone, extract the year and month, and so on. The simpler approach would be to look hard at this data, declare “I’m not interested in accounting for those edge cases”, and use the simpler query immediately above.

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

Sidebar

Related Questions

I have this table: ID(INT) DATE(DATETIME) Under the DATE column there are a lot
I have a table with a date column that I know is stored in
I have table with date/time column and person column. Each person has multiple records
If I have table with a Date column called myDate , with values like
So if I have a table as follows with column date datetime employee varchar
I have a table that contains records with a column indicates the Date. Given
I have a DATE datatype mysql column in a table. I want to set
I have a date in the string format in a table and I need
I have one column in my table which will store data in string format
I have a date column with dates stored as strings, such as 20120817. Unfortunately,

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.