Hello,
I have been trying to calculate the difference between two date and display the difference in hours and minutes (HH:MM). I can't get it calculate properly and I can't hours and minutes to display.
I tried "results=enddate-startdate" dates have month, day, year,and time of day. After this calculation I end up with no results.
Any help would be appreciated.
Walt
7 54899 ADezii 8,834
Recognized Expert Expert
Hello,
I have been trying to calculate the difference between two date and display the difference in hours and minutes (HH:MM). I can't get it calculate properly and I can't hours and minutes to display.
I tried "results=enddate-startdate" dates have month, day, year,and time of day. After this calculation I end up with no results.
Any help would be appreciated.
Walt
I'll illustrate 1 Method by code: - Dim dteStartDateTime As Date, dteEndDateTime As Date
-
dteStartDateTime = #5/20/2007 7:00:00 AM#
-
dteEndDateTime = #5/20/2007 11:15:00 AM#
-
-
Debug.Print "Difference in Hours: " & DateDiff("h", dteStartDateTime, dteEndDateTime)
-
Debug.Print "Difference in Minutes: " & DateDiff("n", dteStartDateTime, dteEndDateTime) - _
-
(DateDiff("h", dteStartDateTime, dteEndDateTime) * 60)
OUTPUT: - Difference in Hours: 4
-
Difference in Minutes: 15
Adezii,
Thanks for the tip! I tried it and it works but my problem is combining the hours and minutes (HH:NN) in records. ex: 4:05, 12:14, etc
I tried to divide the total minutes by 60 but I don't get a remainer. The application is, the time is entered in severalrecords for a job, then I want to be able to sum the hours and minutes from the records and get total time (hours:minutes) for the job.
Thank again
I'll illustrate 1 Method by code: - Dim dteStartDateTime As Date, dteEndDateTime As Date
-
dteStartDateTime = #5/20/2007 7:00:00 AM#
-
dteEndDateTime = #5/20/2007 11:15:00 AM#
-
-
Debug.Print "Difference in Hours: " & DateDiff("h", dteStartDateTime, dteEndDateTime)
-
Debug.Print "Difference in Minutes: " & DateDiff("n", dteStartDateTime, dteEndDateTime) - _
-
(DateDiff("h", dteStartDateTime, dteEndDateTime) * 60)
OUTPUT: - Difference in Hours: 4
-
Difference in Minutes: 15
So after calculating the two, you need to concatenate them: - TimeDifference = [Difference in Hours] & ":" & [Difference in Minutes]
ADezii 8,834
Recognized Expert Expert
Adezii,
Thanks for the tip! I tried it and it works but my problem is combining the hours and minutes (HH:NN) in records. ex: 4:05, 12:14, etc
I tried to divide the total minutes by 60 but I don't get a remainer. The application is, the time is entered in severalrecords for a job, then I want to be able to sum the hours and minutes from the records and get total time (hours:minutes) for the job.
Thank again
- missingling has the correct response about concatenating both differences.
- Look at the code again, you are not dividing by 60. To get the Minutes component you are calculating the total number of minutes difference - (minus) the number of Hours difference * 60.
- missingling has the correct response about concatenating both differences.
- Look at the code again, you are not dividing by 60. To get the Minutes component you are calculating the total number of minutes difference - (minus) the number of Hours difference * 60.
Query will be like as :------------
db2 "select substr(HOSTNAME,1,25) as hostname,ltrim(rtrim(char(timestampdiff(8,char(tim estamp(CLOSETIME)-timestamp(STARTTIME)))))) ||':' || char((int(
ltrim(rtrim(char(timestampdiff(4,char(timestamp(CL OSETIME)-timestamp(STARTTIME))))))))- ( int( ltrim(rtrim(char(timestampdiff(8,char
(timestamp(CLOSETIME)-timestamp(STARTTIME)))))))*60)) as difftime from EVENTS_TIME"
plese will u post this code in c# plssssssssssssssssss
ADezii 8,834
Recognized Expert Expert
This sounds like a question for the C# Forum, not here.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: David Gray |
last post by:
Greetings all,
Quick newbie type question:
I would like to be able to trap non-numerical data entered into a
textbox via CTRL+C and/or Shift+Insert.
I realise that this data can be...
|
by: Manny Chohan |
last post by:
Hi Can anyone tell me how i can calculate yesterday date using asp?
Thanks
manny
|
by: Frank |
last post by:
For my website i would like to display the age of my son in years,
months, days and hours.
For now i manage to get a result for totals. Like the total number of
days.
This is the beginning:
...
|
by: SimonC |
last post by:
Help needed for a Javascript beginner.
As above in the subject... i need a javascript to run this, but not in
the form of a web-page. I want to calculate it between 2 fields in a
database that...
|
by: Steve |
last post by:
Hi all
How would I find out the average date when given a bunch of dates? For
example, I want to find the average length in time from the following dates:...
| |
by: infobescom |
last post by:
Hi
I am wrking on a application where i need to calculate the difference between two dates ..
here is the formula i am using
........
Public Function GetNumberOfWorkDays(sStartDate,...
|
by: lenygold via DBMonster.com |
last post by:
I found this example in MYSQL:
create table events
( id integer not null primary key
, datetime_start datetime not null
, datetime_end datetime not null
);
insert into events values
( 1,...
|
by: student4lifer |
last post by:
Hello,
I have 2 time fields dynamically generated in format "m/d/y H:m".
Could someone show me a good function to calculate the time interval
difference in minutes? I played with strtotime() but...
|
by: FishVal |
last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL.
So, let us say the problem is to calculate...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |