Hi ,
I would like to convert the datadiff to hours,minutes and second and total up batch time and build time in different column . Can expert show how this can be done in below query? -
SELECT file_name, org_rcvd_dts,
-
DateDiff(hh, bld_start_dts, bld_end_dts) AS Batch_time,
-
DateDiff(hh, cnv_start_dts, cnv_end_dts) AS Build_time
-
FROM build_log(nolock)
-
WHERE status <> 'DoNotRerun'
-
AND dist_id = 2
-
AND build_type = 'Full'
-
ORDER BY cnv_start_dts
3 1416
Basically you need to get the DateDiff in seconds, not hours as in your code. Then convert the seconds to hours, minutes and seconds.
So Try -
Dim Hrs as Integer
-
Dim Mins as Integer
-
Dim Secs as Integer
-
-
SELECT file_name, org_rcvd_dts,
-
DateDiff("s", bld_start_dts, bld_end_dts) AS Batch_time,
-
DateDiff("s", cnv_start_dts, cnv_end_dts) AS Build_time
-
FROM build_log(nolock)
-
WHERE status <> 'DoNotRerun'
-
AND dist_id = 2
-
AND build_type = 'Full'
-
ORDER BY cnv_start_dts
-
-
Hrs = BatchTime \ 3600 ' Note the backslash returns only the whole number of hours
-
Mins = (BatchTime - (Hrs * 3600)) \60
-
Sesc - BatchTime - (Hrs * 3600) - (Mins * 60)
-
Note that with the DateDiff function, the time unit is a string and needs to be surrounded with quotes. I doubt that your function with hh and no quotes would have worked.
Phil
Hi Phil,
Thank you. Im using the SQL server and the query is not detected as SQL query. - Declare @num_hours Integer
-
Declare @num_minute as Integer
-
Declare @num_sec as Integer
-
-
-
SELECT file_name, org_rcvd_dts,
-
DateDiff("s", bld_start_dts, bld_end_dts) AS Batch_time,
-
DateDiff("s", cnv_start_dts, cnv_end_dts) AS Build_time
-
FROM build_log(nolock)
-
WHERE status <> 'DoNotRerun'
-
AND dist_id = 2
-
AND build_type = 'Full'
-
ORDER BY cnv_start_dts
-
Where should i declare the conversation part
Whoops, sorry. I was thinking it was Access VBA. Don't know anything about SQL server, so I can't help anymore. I think, providing you can get your query to return the seconds, the conversion to hours, minutes & seconds should work
Again, apologies.
Phil
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Arargorn |
last post by:
I am trying to create a database that involves time calculation (elapsed
time). I have set up several tables and one is for "Time Card" entry. I
cannot figure out how to calculate the elapsed time...
|
by: Alec |
last post by:
Hi All,
I've asked about this before, and people were very helpful, and I have
used the advise quite a bit, however I have run into a spot of
trouble...
I have a form that the users uses to...
|
by: MMFBprez |
last post by:
I am trying to compute storage charges by getting the number of months
between dates and multiplying it by a rate. I cannot get a correct
number of months if the date is greater than a year ago. ...
|
by: guy |
last post by:
Has anyone any experience of the conversion wizard for VB6 to VB2005?
if so how good is it?
also how does it handle database related conversions i.e is ADO converted to
ADO.NET etc.
the project...
|
by: Babak |
last post by:
Hi
I am trying to find a way to fliter a DefaultView to filter Time Stamp
DataTime
For example I want to know if there is any row that have Time stmp greater
then
Today .
The Datadiff function...
|
by: Zerin |
last post by:
To all,
Best regards.I submitted this problem about auto purge a database many days ago but there's no reply till now.If anyone has any solution,please reply as soon as possible.
Is aouto...
|
by: rn5a |
last post by:
In my local computer, date has been set in this format - dd/MM/yyyy.
When I insert records in a MS-Access DB table using ASP.NET, then the
records get inserted in the Access DB table exactly in the...
|
by: aapulido |
last post by:
I'm creating a timekeeping database, and i need help on how to compute the Hoursworked based on In and Out.
Please help me on this
|
by: Brita |
last post by:
You guys have been life savers for me, and I appreciate your help so much.
I am trying to check the difference in days between two submitted requests.
DateFormat df =...
|
by: brendanmcdonagh |
last post by:
Hi all,
I ve discovered the power of php/mysql/html in last few days whilst putting together an online app to enable the staff of a friends company to log on and enter their current location and...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |