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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:47:25+00:00 2026-05-23T17:47:25+00:00

I have a question Can we convert date 20-06-2011 (dd-mm-yyyy) into 0611 using sql

  • 0

I have a question

Can we convert date 20-06-2011 (dd-mm-yyyy) into 0611 using sql (SQL server database) ?

And

Can we count ID below
keeping in mind last 4 digits which represent date (last 4 digits represent date in the form MMYY) so numbers with last 4 digits 0611 count should be 3

What would be the SQl Query for the count?

ID

AOB2340511
AOB4560511
AOB3500611
AOB4410611
AOB5120611
AOB1250411
  • 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-05-23T17:47:25+00:00Added an answer on May 23, 2026 at 5:47 pm

    EDIT: Corrected DATE data type option.

    If your date fields are DATE data types you can do the following.

    SELECT RIGHT('0' + CAST(DATEPART(MM, @TheDate) as VARCHAR), 2)
        + RIGHT(CAST(DATEPART(YY, @TheDate) as VARCHAR), 2)
    

    If your date fields are stored as a string type, such as VARCHAR, NVARCHAR, etc, then try the following

    select SUBSTRING(TheDate, 4, 2) + SUBSTRING(TheDate, 9, 2)
    

    For the question about count, you can try this

    SELECT RIGHT(ID, 4) AS TheDate, Count(*) AS TheCount
    FROM MyTable
    GROUP BY RIGHT(ID, 4)
    

    If you need a query for the count that also shows the ID value, give this a try

    SELECT ID, RIGHT(ID, 4) as MMYY,
        COUNT(*) OVER (PARTITION BY RIGHT(ID, 4)) AS TheGroupCount
    FROM MyTable
    ORDER BY ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question regarding the SQLAlchemy. How can I add into my mapped class
I have a string I need to convert back to a date. I can
I would like my date to be YYYY-MM-DD (DD-MM-YYYY), I can't seem to convert
I have a question that bothers me. How can i convert a varchar to
this question can create a misunderstanding: I know I have to use CSS to
I have not been able to find any definitive answers to this question: Can
I have the following question about JPA: Can I save the order of the
I have a question about JSF and GET http request. How can I get
I have a question about a problem I'm struggling with. Hope you can bear
i have a question, been stuck for a while, i dont know how can

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.