The Original SQL Statement is:
SELECT SA.[RequestStartDate] as 'Service Start Date',
SA.[RequestEndDate] as 'Service End Date',
FROM
(......)SA
WHERE......
The output date format is YYYY/MM/DD, but I want the output date format is DD/MM/YYYY. How can I modify in this statement?
7条答案
按热度按时间nkoocmlb1#
Try like this...
For more info : http://www.sql-server-helper.com/tips/date-formats.aspx
uz75evzq2#
Changed to:
Have no idea which SQL engine you are using, for other SQL engine, CONVERT can be used in SELECT statement to change the format in the form you needed.
wh6knrhe3#
There's also another way to do this-
px9o7tmv4#
Try:
Or:
pvcm50d15#
You will want to use a CONVERT() statement.
Try the following;
See MSDN Cast and Convert for more information.
pvcm50d16#
I was using oracle and I had to select multiple columns and output the date column in YYYY-MM-DD format, and this worked
select <column_1>, to_char(<date_column>, 'YYYY-MM-DD') as <Alias_name> from <table_name>
nimxete27#
SELECT column1, DATE_FORMAT(ColumnName, "%d/%M/%Y") as column2, column3 FROM tableName;
you can see here
w3: https://www.w3schools.com/sql/func_mysql_date_format.asp