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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:56:26+00:00 2026-06-15T19:56:26+00:00

I can’t seem to get this right. I am currently trying to convert one

  • 0

I can’t seem to get this right. I am currently trying to convert one of the columns to a different date format, but my code is not working.

The current format of TrackingNumbers.ShipDate is “MM/DD/YYYY hh:mm:ss AM/PM”, and I am trying to make it convert it to “yyyy-mm-dd”.

SELECT TOP 500 -- Selects the first 500 records for a smaller file
    Orders.PONum AS 'order-id',
    TrackingNumbers.TrackingNumber AS 'tracking-number',
    TrackingNumbers.Gateway AS 'carrier-code',
    CONVERT(VARCHAR(10), TrackingNumbers.ShipDate, 120) AS 'ship-date', 
            -- The date format is currently "MM/DD/YYYY  hh:mm:ss AM/PM"
            -- It needs to be yyyy-mm-dd
    CASE TrackingNumbers.ShippingMethodID   -- Converts the shipping Methods so customers can understand them
        WHEN '900' THEN 'USPS Priority (2-14 days)'
        WHEN '103' THEN 'UPS 2nd Day Air'
        WHEN '108' THEN 'UPS Ground'
        WHEN '112' THEN 'UPS Worldwide Expedited'
        WHEN '214' THEN 'USPS Express Mail Intl'
        WHEN '220' THEN 'USPS Priority (2-14 days)'
        WHEN '505' THEN 'UPS Next Day Air Saver'
        WHEN '207' THEN 'USPS First ClASs (7-30 Days)'
        WHEN '222' THEN 'USPS Express Mail Envelope'
        WHEN '102' THEN 'UPS Next Day Air'
        WHEN '217' THEN 'USPS Priority Mail International'
        WHEN '107' THEN 'UPS 3 Day Select'
    END AS 'ship-method'
FROM
    TrackingNumbers, -- Selects two different tables
    Orders  
WHERE 
    Orders.OrderID = TrackingNumbers.OrderID -- Merges Orders with tracking numbers
    AND 
    Orders.PONum<>'' -- Only grabs orders with a PO number
Order By 
    TrackingNumbers.ShipDate Desc -- Sorts by descending ship date of the package (order ship date can be different)

The 5th line is where the trouble is at. How is it supposed to be formatted?

  • 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-15T19:56:27+00:00Added an answer on June 15, 2026 at 7:56 pm

    From CAST and CONVERT (Transact-SQL), ANSI style (yyyy-mm-dd) in the CONVERT function would seem to be 102 style, not 120, unless I am mistaken.

    How about:

    REPLACE(CONVERT(VARCHAR(10), TrackingNumbers.ShipDate, 102), '.', '-') AS 'ship-date'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Can any one tell, how to get the result of LINQ query contains group
Can anyone tell me what i am doing wrong? I am trying to get
Can somebody help me convert this VB function to Perl (PHP, Ruby or Python
Can any one help me in sorting this out in sed/awk/perl Input file Start
Can find why i get this error can someone help? package Android.data; public class
Can anyone help me trying to find out why this doesn't work. The brushes
Can I make this link in a href format ( ahref ='...' )? <form
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can anyone explain to me why this program: for(float i = -1; i <

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.