| Author |
Topic |
|
cwildeman
Starting Member
40 Posts |
Posted - 2012-03-16 : 16:12:06
|
| I have two fields in an SQL Server table which are TimeCalled and TimeFinished and are datetime. I have an MS Access front end with text boxes where a user enters military time into both boxes. For instances they may enter 17:20 for TimeCalled and 17.30 for TimeFinished with ten minutes being the difference between the two. I want to create a query in SQL Server that converts these two times into an integer (i.e. 10). What is the best way to do this?Thanks,Chuck W |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
flamblaster
Constraint Violating Yak Guru
384 Posts |
Posted - 2012-03-17 : 19:52:30
|
| Wildeman, are you just trying to return a result to show the difference in minutes? If that's the case, you don't actually want to convert the times, you just need to use date functions:select DATEDIFF(mi, Timecalled, TimeFinished)from yourtable |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-18 : 10:43:24
|
quote: Originally posted by cwildeman I have two fields in an SQL Server table which are TimeCalled and TimeFinished and are datetime. I have an MS Access front end with text boxes where a user enters military time into both boxes. For instances they may enter 17:20 for TimeCalled and 17.30 for TimeFinished with ten minutes being the difference between the two. I want to create a query in SQL Server that converts these two times into an integer (i.e. 10). What is the best way to do this?Thanks,Chuck W
how do you want to show the minutes?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
cwildeman
Starting Member
40 Posts |
Posted - 2012-03-18 : 18:53:47
|
| I am going to do a further calculation. I want to sum the total minutes (the total date difference between the start and end date), and then divide by the count of account numbers to get a Time per Account number specified in minutes (i.e. 5.2 minutes per account number).ChuckChuck W |
 |
|
|
flamblaster
Constraint Violating Yak Guru
384 Posts |
Posted - 2012-03-18 : 19:54:50
|
| Did you try the datediff function that I posted above? The result between 1710 and 1720 would be 10 minute difference. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-19 : 00:18:53
|
quote: Originally posted by cwildeman I am going to do a further calculation. I want to sum the total minutes (the total date difference between the start and end date), and then divide by the count of account numbers to get a Time per Account number specified in minutes (i.e. 5.2 minutes per account number).ChuckChuck W
so it will of float format or time format?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
cwildeman
Starting Member
40 Posts |
Posted - 2012-03-20 : 11:18:04
|
| Thanks for everyone's help. I tried select DATEDIFF(mi, Timecalled, TimeFinished) and it worked. I can do calculations off of this as well. ChuckChuck W |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|