Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have created a display part, which displays few details such as
Entry Date,
Verified date,
Name

I want to display a col. as TAT(Date and time format)
TAT=Difference between Entry Date and Verified date
Eg: 1d 6h 33m

This I want to display using SQL. Kindly provide me any suggestion.
Posted

 
Share this answer
 
Comments
Wendelius 1-Sep-12 4:32am    
Yep, good link. 5.
Mehdi Gholam 1-Sep-12 4:33am    
Cheers Mika!
Typically all the formatting should be done on the client side, not using the database.

However, you can use the DATEDIFF function to calculate the difference between to dates and format it as per requirements. For the syntax, see DATEDIFF[^]
 
Share this answer
 
Comments
Mehdi Gholam 1-Sep-12 4:34am    
Agreed it is easier on the client side. 5'ed
Wendelius 1-Sep-12 12:11pm    
Thanks Mehdi :)
Oshtri Deka 3-Sep-12 7:33am    
Correct. 5.
Wendelius 4-Sep-12 16:41pm    
Thanks :)
SQL
Select convert(varchar,Datepart(d,TAT))+'d '+convert(varchar,Datepart(hh,TAT))+'h '+convert(varchar,Datepart(m,TAT))+'m'
from tablename
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900