In my Sybase DB I have a table called employee_leaves. So the select query statement is as shown below:
SELECT EmployeeCode,EmployeeName,ApplicationDate FROM dbo.employee_leaves
Where I have challenge is that the ApplicationDate comes in this format: 16/04/2023 7:09:47.563
From the Select Query statement, I want each of the ApplicationDate to be formatted and displayed as:
2023-04-16 07:09:47.563
yyyy-MM-dd ....
I tried this but not working:
SELECT EmployeeCode,EmployeeName,format(ApplicationDate,'yyyy-MM-dd,hh:mm:ss') FROM dbo.employee_leaves
How do I achieve this from the select * FROM dbo.employee_leaves
Assuming the
ApplicationDatecolumn is defined with a datatype ofdatetime...In
Sybase ASEyou want to look at theconvert()function with a focus on the 3rd argument (aka thestylesetting).For OP's desired format this should work:
NOTES:
ASE 16.0 SP04 GAinstancestylechart you can typically build your own format with a combination of otherconvert(type,column,style),substring(),left(),right()andstr_replace()callsApplicationDatecolumn is defined asvarchar(N)(orchar(N)) then you'll likely need to look at appending a series ofsubstring()calls and literal strings to get the desired output format