Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
NEVerton
Starting Member
9 Posts |
Posted - 2011-09-26 : 09:18:00
|
| Could someone please show me how to calculate the number of minutes between 2 dates (period could be more then 1 day).I tried datediff(n,date1,date2) but this does not work when the period is greater than 1 day.Please help. :-) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-26 : 09:24:18
|
| why it doent work?seeselect DATEDIFF(n,'20110913 13:30','20110914 14:30')it gives you minutes as 1500 which is (24 + 1)*60ie 1 day and an hour transalated to minutes------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
NEVerton
Starting Member
9 Posts |
Posted - 2011-09-26 : 09:36:19
|
| MMM.. Strange!If I do: select datediff(n,'01/01/11 10:00','02/01/11 10:00') The result is 60But if I do: datediff(n,'01/01/11 10:00','02/01/11 11:00')The result is 44700 |
 |
|
|
NEVerton
Starting Member
9 Posts |
Posted - 2011-09-26 : 09:37:57
|
| Oops! Just tried your syntax and it worked... must be my date format! |
 |
|
|
NEVerton
Starting Member
9 Posts |
Posted - 2011-09-26 : 09:43:25
|
| If the date and time fields are seperate can I combine them by adding a +?e.g. date_received+time_received ..... in other words, will this work? select datediff(n,date_receieved+time_received,response_date) |
 |
|
|
vmvadivel
Yak Posting Veteran
69 Posts |
Posted - 2011-09-26 : 10:02:00
|
| Yeah you can concatenate it with a space in between them.SELECT DATEDIFF(n,'20110913' + ' ' + '13:30','20110914' + ' ' + '14:30')Best RegardsVadivelhttp://vadivel.blogspot.com |
 |
|
|
|
|
|
|
|