Hi all.
I have a query which calculates the difference between two date/time fields. This returns a number which is, of course, useless without formatting (“I couldn’t believe it took 1.15740767796524E-05 to do that”). I have formatted this as "hh:nn:ss", and this works OK. But it clocks over at 24 hours, which effectively renders it useless for my purposes. Using "hhh:nn:ss" doesn't work. I forget the details, but it produced nonsense.
So, how can I format an amount of time in a way that will still work when it goes over 24 hours? In fact, the hours could even go to three digits, though rarely.
5 8242 NeoPa 32,556
Expert Mod 16PB
You come up with some good ones Killer.
Try "0 hh:nn:ss"
This does, of course, mean that ALL times are shown including a day indicator.
You come up with some good ones Killer.
Try "0 hh:nn:ss"
This does, of course, mean that ALL times are shown including a day indicator.
Thanks, I'll give it a shot.
the formatting won't work if you used the datediff to get the difference as it returns an integer result. How to do it de[ends on the smallest unit of difference you want to report on. If, for example you want to show hors & minutes the following code works
the formatting won't work if you used the datediff to get the difference as it returns an integer result. How to do it de[ends on the smallest unit of difference you want to report on. If, for example you want to show hors & minutes the following code works
Dim Diffierence as long
Dim FormattedTime as string
Difference = datediff("n",Firstdate,SecondDate)
formattedtime = int(difference/60) & " Hrs " & difference mod 60 & " Min
if you want days, hours & minutes the code would be
formattedtime = int(diference/1440) & " Days " & int((difference mod 1440)/60) & " Hrs " & int((difference mod 1440) mod 60) & " Min"
This code will give you the time diffrenece in days, hrs & minutes for all dates
Thanks for that, Andrew. But I am simply subtracting two date/time fields. The result is a tiny number, see original post for a sample. I am happy with this result, as I often copy/paste the result set to Excel for graphing and so on, and apply the format [h]:mm:ss there, which gives me as many digits as I need for the hours.
I just prefer to have it formatted as an amount of time in Access too, but the hh:nn:ss I was using there is not quite right, and it doesn't recognise the one from Excel.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andreas Emmert |
last post by:
Hi there,
I'm trying to import a csv file into my MySQL database. Unfortunately the
number format for the price column is formatted in German style, i.e. XX,XX
(decimals separated by comma not...
|
by: Peter Jansson |
last post by:
Dear group,
I have been struggling to get a simple program for inserting and
extracting std::tm objects to/from streams to work. The code below tries
to read a std::tm object from a...
|
by: ApexData |
last post by:
Hello
Any know how to convert AM/PM Time to 24Hr Time ?
Sample Please ! With and without Now().
ThankYou
Greg
|
by: nb |
last post by:
Hi
I am using Ole Db to get data from MS Access into my C# windows application.
In the database file, there is a column with datatype 'Datetime' and format
'Short Time'. However, in my C#...
|
by: Rick |
last post by:
With String.Format, if I have an incorrect number of args specified for a
format string, compile fails. How can I implement similar design-time
functionality for my own string functions?
|
by: =?Utf-8?B?ZGNoMw==?= |
last post by:
Is there a way to conditionally format a dateTime field to produce on result
if the value is 10/31/2008 12:00 AM (user didn't enter a time) and another
result if the value is 10/31/2008 5:30 PM...
|
by: Rotorian |
last post by:
Good Morning,
I have a table which has a "Date" field and a "Time" field. The "Date" field is format "Short Date" with a default value of "Date()" The "Time" field is format "Short Time" and the...
|
by: mamunur rashid |
last post by:
I am using following function and I want time in 24hr clock format but this gives me time in 12hrs:
<?php
date_default_timezone_set('Etc/GMT+6');
$timestamp = date("Y-m-d H:i:s", time());...
|
by: neelsfer |
last post by:
I need to add milliseconds to this finishtime of race
!!! = Format(Now(), "General Date")
Start code for race also in milliseconds
!!! = Format(Now(), "General Date")
I will then subtract it...
|
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
| |