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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:05:29+00:00 2026-05-23T11:05:29+00:00

i have the following table with values mentioned below.I have a label which shows

  • 0

i have the following table with values mentioned below.I have a label which shows the date from the table.for the first date it should display as 07/06/2011 and from the second date it should display as below format,any one help me..

“Label:07/07/2011 to 07/13/2011 ” ,

ID  Date                  
==  ==========
63  07/06/2011         
64  07/13/2011         
65  07/20/2011         
66  07/27/2011         
67  08/03/2011   
  • 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-23T11:05:30+00:00Added an answer on May 23, 2026 at 11:05 am

    Try this:

    WITH qry AS
    (
        SELECT a.*,
               ROW_NUMBER() OVER(ORDER BY Date) rn
          FROM MyTable a
    )
    SELECT a.Id,
           CASE 
            WHEN b.Id IS NULL THEN CONVERT(VARCHAR, a.Date, 101) 
            ELSE 'Label: ' + 
                  CONVERT(VARCHAR, b.Date + 1, 101) + 
                  ' to ' + 
                  CONVERT(VARCHAR, a.Date , 101) 
           END AS Date
      FROM qry a LEFT JOIN qry b
        ON a.rn  = b.rn+1
    

    Table Setup:

    CREATE TABLE MyTable (ID INT, DATE DATETIME)
    INSERT INTO MyTable VALUES(63,'07/06/2011');
    INSERT INTO MyTable VALUES(64,'07/13/2011');
    INSERT INTO MyTable VALUES(65,'07/20/2011');
    INSERT INTO MyTable VALUES(66,'07/27/2011');
    INSERT INTO MyTable VALUES(67,'08/03/2011');
    

    Results:

    Id  Date
    63  07/06/2011
    64  Label: 07/07/2011 to 07/13/2011
    65  Label: 07/14/2011 to 07/20/2011
    66  Label: 07/21/2011 to 07/27/2011
    67  Label: 07/28/2011 to 08/03/2011
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: $sql = INSERT INTO table VALUES ('', ...); $result
I have the following Python code: cursor.execute("INSERT INTO table VALUES var1, var2, var3,") where
I have the following query in VBA: DoCmd.RunSQL INSERT INTO table (value) VALUES ('example')
I have 2 tables A and B with following records --TABLE A-- id date
Let's say I have to following table with values (1st row is the description)
I have a table which contains the following columns: UniqueID remote_ip_addr platform I want
I have the following table (id, Tag) with the following values (1, 17) (1,
My Schema I have the following tables table notes/example values ------------------------------------------------ users ( id
I have the following table called [Store_Sales] - Store Date Sales 1 23/04 10000
I have the following table >anna2 name from to result 11 66607 66841 5

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.