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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:16:05+00:00 2026-06-06T14:16:05+00:00

my dates in my table are strings in the format: 10/12/2009 Now how would

  • 0

my dates in my table are strings in the format:

"10/12/2009"

Now how would one get all the records from a month, lets say June (number “6” being provided)?

  • 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-06T14:16:07+00:00Added an answer on June 6, 2026 at 2:16 pm

    The short answer to your question is that you can use the STR_TO_DATE and MONTH functions to 1) convert the string representation into a DATE, and 2) extract the month component from the date:

    SELECT t.*
      FROM mytable t
     WHERE MONTH(STR_TO_DATE(t.dateasstringcol,'%M/%d/%Y')) = 6
    

    (This is assuming here that by ’10/12/2009′, you are specifying Oct 12, and not Dec 10. You’d need to adjust the format string if that’s not the case.)

    Alternatively, if month is indeed the leading part of the date, you could do a simple string comparison, if the month is the leading component:

    SELECT t.*
      FROM mytable t
     WHERE t.dateasstringcol LIKE '6/%' 
        OR t.dateasstringcol LIKE '06/%'
    

    (You could eliminate one of those predicates, if you have an exact format specified for the striing value representing the date: either if month is always stored as two digits -OR- the month is never stored with a leading zero.)

    If you are passing in an argument for the month, e.g. ‘6’, then you could construct your statement something like this:

     WHERE t.dateasstringcol LIKE '6' + '/%'
    

    If month is the second component of the date, then you could use:

    SELECT t.*
      FROM mytable t
     WHERE t.dateasstringcol LIKE '%/' + '6' + '/%' 
        OR t.dateasstringcol LIKE '%/' + '06' + /%'
    

    NOTE:

    All of the previous example queries will return rows for June of any year (2009, 2010, 2011)

    You can extend those examples, and do something similar with the year, using the YEAR function in place of the MONTH function, or for string comparison

        AND t.dateasstringcol LIKE '%/%/2011'
    

    Normally, we’d extract rows for a particular month for a particular year, using a date range, for example:

    SELECT t.*
      FROM mytable t
     WHERE MONTH(STR_TO_DATE(t.dateasstring,'%M/%d/%Y')) >= '2011-06-01'
       AND MONTH(STR_TO_DATE(t.dateasstring,'%M/%d/%Y')) <  '2011-07-01'
    

    Of course, when the date value is stored as a DATE datatype rather than as a VARCHAR, this means we don’t need the STR_TO_DATE and MONTH functions, we can specify a comparison to the native DATE column. This approach allows us to make use of an index on the date column, which can improve query performance on large tables.

    SELECT t.*
      FROM mytable t
     WHERE t.realdatecol >= '2011-06-01'
       AND t.realdatecol <  '2011-07-01'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get Dates from RepDailyInfo table when the RepDailyCollection.IsReceived = 0
In one of my Mysql database table the dates are stored in the format
I'm trying to get a list of dates from my table, which contains a
In my table dates are stored in the format 2010-08-26 09:00:00 so yyyy-mm-dd. I'd
Using SqlServer 2000 and VB6 Table Dates 10/10/2009 (dd/mm/yyyy) 11/10/2009 .... .... Dates Column
I'm using a system where the dates are stored as strings in the format
On my website we store all time & date in the following format: Table
I have a table where unfortunately a number of dates are stored as strings.
I've have a date field in my table that stores dates from a form
got a table with dates and prices. Date Price 2012-01-01 25 2012-01-05 12 2012-01-10

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.