MS Access to SQL server 2008
-
Thursday, September 20, 2012 6:18 PM
Hi All - I am entirely new to SQL Server - can anyone please help me in converting the following
from access to SQL Server 2008
in ACCESS =sum([mytable]![end]-[mytable]![start]) * 24 +
sum([mytable]![end]-[mytable]![start]) *8
start - data type in SQL Server 2008 is dateime values look
like 2012-01-25 15:22:48.000
end - data type in SQL Server 2008 is datetime values
look like 2012-01-25 15:18:40.437 I basically need the total number of hours and mins only
something like 22:10 (twenty two hours and 10 mins)
thank you in advance for your help and time
- Moved by Iric WenModerator Tuesday, September 25, 2012 3:18 AM (From:SQL Server Data Access)
All Replies
-
Thursday, September 20, 2012 7:42 PMHi All - can anyone please help me on this - i am still looking into previou posts
-
Tuesday, September 25, 2012 3:19 AMModerator
Hi SQLServerRaj,
Since this forum is for SQL Server, and not all of the communities know the access query. So, could you post the sample table and describe your requirement for the query?
Best Regards,
Iric
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
Tuesday, September 25, 2012 5:20 PMModerator
Try using DATEDIFF function to get the difference in seconds (assuming your two dates are not too far apart) and then do a basic math to get days, hours, minutes from the seconds value.
See also http://bytes.com/topic/sql-server/answers/143394-convert-seconds-hours-minutes-seconds
For every expert, there is an equal and opposite expert. - Becker's Law
My blog- Proposed As Answer by Iric WenModerator Tuesday, October 02, 2012 8:16 AM
-
Sunday, September 30, 2012 8:58 AMModerator
The following article is on datetime conversion & date and time functions:
http://www.sqlusa.com/bestpractices/datetimeconversion/
If you convert datetime to string, you can truncate the seconds and milliseconds with the LEFT() or other string functions.
Kalman Toth SQL SERVER 2012 & BI TRAINING
New Book: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2012- Edited by Kalman TothMicrosoft Community Contributor, Moderator Sunday, September 30, 2012 9:00 AM

