Interview Feeds

Interview Questions and Answers Guide

Friday, June 13, 2008

Date sorting issue in TSQL!

In MS SQL Server 2000 on back end and on front end i tried to to show the data while accessing data from table i was trying to sort date in descending order but it shows below invalid order.


the exact order that i wants was


which was not coming in front so me for this i tried the blow methods.
Even i used below code in c# to sort my data table before its display but still sorting is not valid.
//datatable is populated before all the below lines
//we can assign datatable as DataScource to data grid and bind also
//but the result will be the same as i discussed in this pose
DataView dv = datatable.DefaultView;
dv.Sort = "TaskDate";
// "TaskDate" is column of datatable
this.dgTaskReport.DataSource = dv;
//dgTaskReport is data grid name

But actually i was populating the datatable using stored procedure and in my stored procedure i was getting the date as it so the stored procedure was taking date as string now i converted the date into exact date formate so the sorting is fine as i want.
stored procedure is as under

IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'spBookTask' AND type = 'P')
CREATE PROCEDURE spBookTask ( @bookid varchar(50))
SELECT dbo.ufn_GetDateOnly(tblTaskSheet.TaskDate) as TaskDate
FROM tblTaskDetails
WHERE (tblTaskDetails.BookId = @bookid)
Order by convert(varchar(16), tblTaskDetails.TaskDate, 101) asc

spBookTask '10003'

Muhammad Hussain
Global Guide Line Team.
Copyright © 2005-2006 All rights reserved.


Muhammah Hussain Iqbal said...

Nice Article

Anonymous said...

the HTML is very basic coding language of software fields but java script is very difficult to

quickheed said...

thanks for the good article. keyword research, competition analysis, on-page and off-page are the topics included in seo tutorial. this website is offering free seo tutorial with practical explanation.seo tutorial

Anonymous said...

Share the SAP Material Interview question for Freshers,
Link as,
sapTraining in Chennai

Roshini Balu said...

Thanks for sharing this valuable information to our vision, if anyone looking a sap training in Velachery
visit the link

Roshini RS said...

Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
sap training in Chennai

murali karthik said...

Thanks for sharing this informative blog. SAP CRM is used for maintaining and managing relationship with customers by firm. If you want to know more about SAP, please visit FITA located at Chennai Velachery.
SAP Course in Chennai

Vinoth Kumar said...

Wiztech Automation Solutions is the Best Training institute in Chennai,started in the year 2006 and it extended its circle through providing the best Education as per the Global Quality Standards. Hence our Training Center in Chennai was Recognized by IAO and ISO for its inspiring Education Quality Standards. Wiztech Automation Solution, the PLC SCADA Training Academy in Chennai offers both PLC, SCADA, DCS, VFD, Drives, Control Panels, HMI, Pneumatics, Embedded systems, VLSI, IT, Web Designing, AutoCad Training courses in chennai with latest various brands. Wiztech Automation Solutions offers Real Time Training Courses with 100% Placement support in chennai.

PLC Training in chennai
SCADA Training in chennai
PLC Training Institute in chennai
Embedded System Training in chennai
VLSI Training in chennai
Automation Training in chennai
Industrial Automation Training in chennai
Process Automation Training in chennai
DCS Training in chennai
Inplant Training in chennai
PLC Course in chennai
Best PLC Training in chennai
PLC Training in chennai
Robotics Training in chennai
Embedded Training in chennai
IT Training in chennai
Web designing Training in chennai
AutoCad Training in chennai

Vinoth Kumar said...

Welcome to Wiztech Automation - Embedded System Training in Chennai. We have knowledgeable Team for Embedded Courses handling and we also are after Job Placements offer provide once your Successful Completion of Course. We are Providing on Microcontrollers such as 8051, PIC, AVR, ARM7, ARM9, ARM11 and RTOS. Free Accommodation, Individual Focus, Best Lab facilities, 100% Practical Training and Job opportunities.

Embedded System Training in chennai
Embedded System Training Institute in chennai
Embedded Training in chennai
Embedded Course in chennai
Embedded Systems Course in chennai
Best Embedded System Training Institute in chennai
Best Embedded System Training Institutes in chennai
Embedded Training Institute in chennai
Embedded System Course in chennai
Best Embedded System Training in chennai
VLSI Training in chennai

Nithya Sri said...

Thank you for sharing such a great blog with us. expecting for your.

Php Training | Php Training in Chennai | Php Training Institute in Chennai | Php Training Institute

Selenium Training | Selenium Training in Chennai | Selenium Course | Selenium Course in Chennai

Salesforce Training | Salesforce Training in Chennai | Salesforce Course | Salesforce Course in Chennai

Subscribe via email

Enter your email address:

Delivered by FeedBurner