|
-
Feb 1st, 2006, 03:49 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Convert Hours Mintues and seconds into decimal
If I have 5:32:43 (5 hours 32 Minutes and 43 Seconds) is there a function to turn this into decimal (5.5453)
Thanks
-
Feb 1st, 2006, 03:57 PM
#2
Thread Starter
Addicted Member
Re: Convert Hours Mintues and seconds into decimal
That just seems to put it in the format 5:32:43? Is there a way to make it change it to decimal?
-
Feb 1st, 2006, 03:59 PM
#3
Re: Convert Hours Mintues and seconds into decimal
.5453 is the decimal fraction equilivalent of :32:43?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 1st, 2006, 04:00 PM
#4
Re: Convert Hours Mintues and seconds into decimal
Code:
Value = CDbl(CDate("5:32:43")) * 24
Value will be 5.54527777777778
-
Feb 1st, 2006, 04:01 PM
#5
Thread Starter
Addicted Member
Re: Convert Hours Mintues and seconds into decimal
-
Feb 1st, 2006, 04:03 PM
#6
Thread Starter
Addicted Member
Re: Convert Hours Mintues and seconds into decimal
THank you CVMichael thats what I was looking for
-
Feb 1st, 2006, 04:04 PM
#7
Re: [RESOLVED] Convert Hours Mintues and seconds into decimal
Welcome...
Don't forget to mark the tread as Resolved from Thread Tools Menu
[Edit]
Ah... I was slow on that... you already did
-
Feb 1st, 2006, 04:16 PM
#8
Re: [RESOLVED] Convert Hours Mintues and seconds into decimal
Just a note:
The Date data type is actually stored as a double, so the previous you can even do as:
Code:
Value = #5:32:43# * 24
If you want to add a day (for example) to the date, you can do:
To add a todays date to a time value:
Code:
TodaysDateAndTime = Date + #5:32:43#
To find out how many days are between 2 dates:
Code:
Days = #2/1/2006# - #2/20/2006#
Etc.
So, since it's stored as a double, you can do mathematical calculations with it...
where
1 is one day
1 / 24 = 4.16666666666667E-02 is one hour
1 / 24 / 60 = 6.94444444444444E-04 is one minute
and finally
1 / 24 / 60 / 60 = 1.15740740740741E-05 is one second
So if you want to add one second to a time: #5:32:43#
You do
Code:
Debug.Print #5:32:43# + 1.15740740740741E-05
Returns: 5:32:44 AM
I know, I know... more than you asked for... sorry...
But it's good to know
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|