Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a datetime column in a table, I am performing a select statement on the table and ordering by the datetime column. Previously the order of the data was correct as all the dates were in 2007. However the last few days have seen the introduction of 2008 dates. As a result, the order of the dates as slightly off in that 2008 dates appear at the bottom of the list while 2007 dates appear at the top. Here is the query that I am using:

 

SELECT     dbo.Timesheets.Id, CONVERT(varchar, dbo.Timesheets.[Date], 103) AS [Date], dbo.Timesheets.Hours, 
		dbo.Timesheets.Comments,  dbo.Timesheets.Offsite,  dbo.ParentProjects.Name as Parent, dbo.ChildProject.Name as Child, 
			dbo.Timesheets.Hour, dbo.Timesheets.Minute, CONVERT(varchar, Hour) + ':' + CONVERT(varchar, Minute) AS times
FROM         dbo.Timesheets INNER JOIN
            		         dbo.StaffList ON dbo.Timesheets.Employee = dbo.StaffList.EmployeeId INNER JOIN
	                      dbo.ParentProjects ON dbo.Timesheets.Parent = dbo.ParentProjects.ProjectID INNER JOIN
		                      dbo.ChildProject ON dbo.Timesheets.Child = dbo.ChildProject.MProjectID
WHERE     (dbo.StaffList.Username = @Employee)
ORDER BY dbo.Timesheets.[Date] DESC, Id Desc, times

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

Solved the problem, by changing the order by statement to the following:

ORDER BY DATEDIFF(WEEK, '2003-05-24', dbo.Timesheets.Date) DESC, Id Desc, times

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...