私はこれを正しく理解できないようです。現在、列の1つを別の日付形式に変換しようとしていますが、コードが機能していません。
TrackingNumbers.ShipDateの現在の形式は「MM/DD / YYYYhh:mm:ss AM / PM」であり、「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)
5行目は問題が発生している場所です。どのようにフォーマットされるのですか?