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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:12:35+00:00 2026-05-23T00:12:35+00:00

I am using SQL 2008. (in asp actually). SELECT orderId, CONVERT(varchar, orderDate, 101) AS

  • 0

I am using SQL 2008. (in asp actually).

SELECT  orderId, CONVERT(varchar, orderDate, 101) AS Date_Ordered, CONVERT(varchar, sentDate, 101) AS Date_Shipped, 
FROM orders 
GROUP BY orderId, CONVERT(varchar, o.orderDate, 101), CONVERT(varchar, o.sentDate, 101)
ORDER BY Date_Shipped

OK, The reason I am using the Convert in the Select is because my Data has Dates with different times. but I want all results with the same Day. So I used the convert.

My problem is that I can not figure out how to do the Order By.
I tried sorting by Date_Shipped, but its now a String so it does not sort properly.

Can anyone help?

  • 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-23T00:12:36+00:00Added an answer on May 23, 2026 at 12:12 am

    You have SQL Server 2008 so you can use the date type

    SELECT
        orderId,
        CONVERT(varchar, orderDate, 101) AS Date_Ordered,
        CONVERT(varchar, CAST(sentDate as date), 101) AS Date_Shipped
    FROM orders 
    GROUP BY
       orderId, CONVERT(varchar, o.orderDate, 101), CAST(sentDate as date)
    ORDER BY
       CAST(sentDate as date)
    

    I can’t recall exactly if this is allowed but hopefully you get the idea: if not, use this

    SELECT
        orderId,
        Date_Ordered,
        CONVERT(varchar, sentDate2, 101) AS Date_Shipped
    FROM
        (
        SELECT
            orderId,
            CONVERT(varchar, orderDate, 101) AS Date_Ordered,
            CAST(sentDate as date) AS sentDate2
        FROM orders o
        GROUP BY
           orderId, CONVERT(varchar, orderDate, 101), CAST(sentDate as date)
        ) foo
    ORDER BY
        sentDate2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I properly convert two columns from SQL (2008) using Linq into a
I'm building an ASP.Net/MVC application using SQL 2008 Developer edition and a DB in
We have a wonderful ASP.NET MVC 2 web application using MS SQL 2008 and
I am busy creating a asp.net web site and using MS SQl 2008 as
I'm using ASP.NET 4, EF 4 and FILESTREAM in SQL 2008 to add/read files
I am using MS SQL 2008 to develop one system with Classic ASP. I
I'm developing ASP.NET 4.0 Website using SQL server 2008 with Membership Framework. It runs
I am developing a asp.net application and i am using SQL Server 2008. I
I'm using SQL Server 2008 with Advanced Services on my Vista Home Premium. I'd
I'm using SQL Server 2008 Management studio viewing a 2005 server and have just

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.