Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
select DATEDIFF(day,allocate_date,deallocate_date) as dDiff from ward




help me to convert date/time from string
Posted

SQL
try below one

select DATEDIFF(day,CONVERT(DATETIME,allocate_date),CONVERT(DATETIME, deallocate_date)) as dDiff from ward  

let me know it help you or not
 
Share this answer
 
Comments
Member 10694442 7-Apr-14 10:04am    
no its not working
Suk@nta 7-Apr-14 10:20am    
what is the data type for allocate_date and deallocate_date and which database you are using
Member 10694442 7-Apr-14 10:25am    
varchar
Member 10694442 7-Apr-14 10:30am    
sql database
Suk@nta 7-Apr-14 10:40am    
means sql server or mysql
SELECT DATEDIFF(day,'2008-06-05','2008-08-05') AS DiffDate
this is format ..........I think your allocate_date,deallocate_date are not in date format ...convert it to date

CONVERT(VARCHAR(19),GETDATE())
CONVERT(VARCHAR(10),GETDATE(),10)
CONVERT(VARCHAR(24),GETDATE(),113)
The result would look something like this:

Nov 04 2011 11:45 PM
11-04-11
04 Nov 2011 11:45:34:243
 
Share this answer
 

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