15,960,736 members
See more:
Hi friends,

I have a table in database which contains three columns :

2. end with datatype datetime
3. and the third column difference,

Now what I want is the difference should show the difference of other two columns in days hours min sec

What should I do so that whenever I write query select * from [tableName] difference show the difference of other 2 column.

thanks
Posted
Updated 13-Oct-10 0:08am
v2
Sandeep Mewara 13-Oct-10 5:50am
Violation of 3-NF!
Dalek Dave 13-Oct-10 6:08am
Edited for Grammar and Spelling.

## Solution 1

Various ways to do this discussed here[^].

You can choose whichever method suits your requirement.

dahras 13-Oct-10 6:18am
thanks

## Solution 2

Why do you need the third column? cannot you use the DATEDIFF[^] function in your query?

:)

Dalek Dave 13-Oct-10 6:08am
Good Call Carlo.
dahras 13-Oct-10 6:18am
thanks plz have a look at next answer thanks

## Solution 4

Let me know that u want to get difference of dates in datetime or no of days.if no of days. u can choose
select DATEDIFF(day,GETDATE(),GETDATE()+1)

dahras 13-Oct-10 6:30am
i wanna get the dates from the column value. but how ?
Mohd Wasif 13-Oct-10 6:50am
how u are inserting date difference in third column, i don't think there should be use of 3 column.

## Solution 3

thanks pallini,

VB
`DATEDIFF (datepart ,startdate ,enddate )`

but the startdate and enddate are contained as column value and i have to calculate the time difference in each row.

i have a query:

SQL
```DECLARE @INT INT

SET @INT = DATEDIFF(SECOND,GETDATE(),GETDATE()+1)

select
convert(varchar(10), (@INT/86400)) + ':' +
convert(varchar(10), ((@INT%86400)/3600)) + ':'+
convert(varchar(10), (((@INT%86400)%3600)/60)) + ':'+
convert(varchar(10), (((@INT%86400)%3600)%60)) as 'DD:HH:MM:SS'```

how can i add the value of colums so that it could display me the time difference of complete table.

thanks