SQL Cast from unixtime Year in general format that Excel can recognize

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
888
Office Version
  1. 365
Platform
  1. Windows
I hope I have the right forum for this question...

I am very new to SQL and have this command text where this line is bringing in the year of shipped data. However Excel does not recognize the data.
I can fix this by doing a text to column and selecting General but I do not want to do this every time I open the sheet.

Is there anyway to format what is coming through as "General" recognized by Excel?

The line giving me issue is: FROM_UNIXTIME(t2.date_shipped, '%Y') AS Shipped Year,

The entire code is:

SQL:
SELECT
FROM_UNIXTIME(t2.date_shipped, '%b') AS `Shipped Month`,
FROM_UNIXTIME(t2.date_shipped, '%Y') AS `Shipped Year`,
COUNT(*) AS "Count of Work Orders Shipped"

FROM
erp_workorder AS t1
LEFT JOIN
  erp_shipping AS t2
ON
  t1.id_primary = t2.id_workorder   
WHERE
t2.date_shipped <> 0
AND
t2.date_shipped > UNIX_TIMESTAMP() - ((107000 * 30) * 30)
GROUP BY IFNULL(FROM_UNIXTIME(t2.date_shipped, '%m'), 0), IFNULL(FROM_UNIXTIME(t2.date_shipped, '%Y'), 0)
ORDER BY IFNULL(FROM_UNIXTIME(t2.date_shipped, '%Y'), 0), IFNULL(FROM_UNIXTIME(t2.date_shipped, '%m'), 0)

Thank you to anyone who can help!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top