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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:35:31+00:00 2026-06-17T16:35:31+00:00

Can anyone help with this problem, I’m trying to select the last 12 month

  • 0

Can anyone help with this problem, I’m trying to select the last 12 month of dates from table, then change the format so that the date appears as:

Feb 2013

Jan 2013 etc

I can change the format to above, but that changes the date to string which then makes it impossible to order DESC.

How can I keep the above format, and still order by desc

SELECT DISTINCT TOP 12 
--CONVERT(date, NewsDatePosted, 120) AS ArchiveTravelNewsByMonth
--CONVERT(CHAR(4), NewsDatePosted, 100) + CONVERT(CHAR(4), NewsDatePosted, 120) AS MY
--DatePart(Year,NewsDatePosted) AS YearPosted 
--datename(month,NewsDatePosted) + ' ' + DatePart(Year,NewsDatePosted) AS YearPosted
FROM dbo.at_News
order by ArchiveTravelNewsByMonth DESC

Thanks

George


SELECT DISTINCT TOP 12 SUBSTRING(CONVERT(VARCHAR(11), NewsDatePosted, 113), 4, 8)
AS ArchiveTravelNewsByMonth,
NewsDatePosted
FROM dbo.at_News
ORDER BY CONVERT(DATETIME, CONVERT(CHAR(4), NewsDatePosted, 100) + CONVERT(CHAR(4), NewsDatePosted, 120))
  • 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-17T16:35:32+00:00Added an answer on June 17, 2026 at 4:35 pm

    Please try by adding an order by clause and inner select like

    SELECT 
        ArchiveTravelNewsByMonth, 
        NewsDatePosted
    FROM(
        SELECT DISTINCT TOP 12 SUBSTRING(CONVERT(VARCHAR(11), NewsDatePosted, 113), 4, 8) AS ArchiveTravelNewsByMonth,
            NewsDatePosted
        FROM dbo.at_News)x
    ORDER BY CONVERT(DATETIME, ArchiveTravelNewsByMonth)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can anyone help me solve this problem? i've been trying to query this but
Can anyone help me spot the problem on this PLEASE? I'm eternally grateful for
Can anyone help me with this problem please? I have 2 databases on the
Hi I was wondering if anyone can help with this PHP problem. Is it
Can anyone help me with this problem I have. Quite hard to summarise into
Can anyone help me out of this problem, my javascript has an ajax GET
Can anyone help me with this problem. I've use 2 login buttons which is
Can anyone help solve this problem, no matter what i try i cannot display
Wonder if anyone can help me with this problem. I have created a Window
echo <p id='xlday'>'$_POST['day']'</p>; Hi can anyone help me solve this problem, should be a

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.