Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
Function: Fraction of Day to Time
Logged in as: Guest
arrSession:exec spGetSession 2,16,38018
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
Post a VBScript
>> Function: Fraction of Day to Time
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
Function: Fraction of Day to Time -
9/22/2006 10:32:00 AM
Skie
Posts: 58
Score: 0
Joined: 3/2/2006
Status:
offline
This is useful when pulling times from Excel or another program that stores time values in fractions of a day.
Function Frac2Time(iDayValue) 'iDayValue is the time when stored as a fraction of a day. (0 = 12:00:00 AM, .875 = 9:00:00 PM, etc.) If iDayValue >= 0 and iDayValue < 1 Then 'Fractions of a day cannot be negative and must be less than 1. OneSec = 1/24/60/60 'One second converted to a fraction of a day TotalSecs = iDayValue/OneSec 'Time in seconds Secs = TotalSecs Mod 60 TotalMins = (TotalSecs - Secs)/60 'Time in whole minutes Mins = TotalMins Mod 60 Hours = cInt((TotalMins - Mins)/60) Frac2Time = FormatDateTime(Hours & ":" & Mins & ":" & Secs) 'Returns time Else wscript.echo "Invalid fraction of day." Frac2Time = -1 'Returns -1 if invalid fraction of day End If End Function
Example of Calling Function:
Set objWorkbook = objExcel.Workbooks.Open ("C:\test.xls") ExcelTime = Frac2Time(objExcel.Cells(1,1).Value) If ExcelTime <> -1 wscript.echo ExcelTime objExcel.Quit
Post #: 1
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
Post a VBScript
>> Function: Fraction of Day to Time
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI