Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002

    Question Unanswered: Sorting a date column

    hi all,

    I have query which diplays require information for my application. Query is given below:

    SELECT distinct POProjects.ProjectId,POProjects.PINNo,POProjects.C ustName,POProjects.ProjName,
    convert(varchar(10),POProjects.ProjectStartDate,10 3) ProjectStartDate,
    convert(varchar(10),POProjects.ProjectEndDate,103) ProjectEndDate,
    dbo.get_emp_name(POProjects.ProjHeadAlias) ProjectHead,dbo.Get_All_PM_Names(POProjects.Projec tId) ProjectManager, dbo.get_emp_name(POProjects.GroupheadAlias)GroupHe ad,POProjects.ProjType,POProjects.EstPersonMonths, POProjects.ProjectStatus,POProjects.PeakTeamSize PeakTeamSize,dbo.Technologylist(POProjects.Project Id) Technology FROM POProjects,POProjectPMs where POProjects.ProjectId=POProjectPMs.ProjectId
    order by POProjects.ProjectStartDate

    Problem is that, though i am using order by statement to sort the projectstartdate column, i am not getting the desired results. Start date and endate are declared as datetime datatypes. I am using convert function since i need only the date part in my application. Can any one suggest me regarding this.

    Thanks in advance,

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    you are converting the date to dd/mm/yyyy string format, then assigning an alias name that is the same as the column name, so you are actually sorting dd/mm/yyyy as strings

    try this

    ... convert(varchar(10),POProjects.ProjectStartDate,103) as ProjectStartDate_
    ... order by POProjects.ProjectStartDate

    if i need a good alias name e.g. as a column header that conveys more meaning than "Expr1", i make it similar, yet still different as far as the syntax is concerned, by appending an underscore


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts