sql server - SQL to display and order by converted date -


Is it possible to use SQL to display dates in a new format? Sort by dd-mm-yyyy and then convert to date?

I tried to do something like:

  Select convert (varchar (10), [date departure], 105) AS [departure from date] It is still sorted by VARCHAR (varchar (10), [date departure], 105) DESC  

It is not working on MS SQL Server.

Order from unchanged date:

  SELECT CONVERT (varchar (10 ), [Date Departure], 105] AS [departure from Date] Departure date from [Date Departure] DESC  

You still have the actual date even if you have your selection list In a different format, the date is selected.

In addition to this, the column has been named [date time] so that order by clause, I do not think that I will have the nickname order by clause against the column real field name, you would think that whenever you apply , Then referring to the column names aligning the actual field names are referring to aliens. So if you order through a column that you give the nickname that has a name similar to a real field on the table, it will be sorted by the result of the previous column, not the actual field on the table.

You can use this if you want to use [date departure] as the column name:

  Choose convert (varchar (10), [ Date departure], 105 [Date departure] << Code> 

This converts the result column to a date.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -