My sql :
SELECT....., date_ of_ shipment,.....
FROM......
WHERE.....
ORDER BY....
After that it will export to excel.
My problem: Some times I get a column of mixing date format MMDDYY and number.?
I have to format the whole excel column to get all date format.
My question: How can I write sql so it force the the result to be date format MMDDYY in excel? Where this clause in sql (where clause ?)
Thanks
Daniel
Code Snippet
select convert(varchar(8), getdate(), 1)
OR
select replace(convert(varchar(8), getdate(), 1), '/', '')
Depending on whether you want the slash separators or not.
Use code 101 instead of 1 in the Convert if you want 4 digit years.
|||If my column name is date_of _shipment
Select convert (varchar(8), date_of_shipment,1) ?
Thnks
Daniel
|||Right.
It will also lose it's name, so you may want to re-alias it.
Code Snippet
Select convert (varchar(8), date_of_shipment,1) AS date_of_shipment
|||Thanks a millions. Look like it work great for what ever my excel column format.
Daniel
|||I may need hour: min: second too
How about MMDDYYYYHHMMSS ?
Thanks
Daniel
 
No comments:
Post a Comment