kctvt Posted October 31, 2016 Share Posted October 31, 2016 Hi everybody, I have problem when convert Time in Excel to text. So, i need help. This is my code : Spoiler $LastTime = _Excel_RangeRead($oWorkbook, Default, "B"&$LastRow) MsgBox($MB_SYSTEMMODAL, "", "Last time is : " & $LastTime) My last time in excel is : 08:37:00 But, MsgBox show : "0.35902777777777778" .... So, how to convert Time in Excel to text 08:37:00 in MsgBox ? Link to comment Share on other sites More sharing options...
water Posted October 31, 2016 Share Posted October 31, 2016 You will find a description plus a conversion function in the wiki:https://www.autoitscript.com/wiki/Excel_UDF#Date_and_Time kctvt 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
kctvt Posted October 31, 2016 Author Share Posted October 31, 2016 50 minutes ago, water said: You will find a description plus a conversion function in the wiki:https://www.autoitscript.com/wiki/Excel_UDF#Date_and_Time Hi Water , I used this code, it worked Thanks Spoiler #include <Date.au3> $nExelDateTime = 42567.25 ConsoleWrite(_ConvertSerialDateTime($nExelDateTime) & @CRLF) Func _ConvertSerialDateTime($nDT) Local Const $dtExcel = '1899/12/31 00:00:00' Local $iDate = Int($nDT) - 1 ; Adjusted after reading wiki and why result is 1 day to much: http://www.cpearson.com/excel/datetime.htm Local $iTime = Mod($nDT, 1) $iTime = Int(24 * 3600 * $iTime) $dtRes = _DateAdd('D', $iDate, $dtEXcel) $dtRes = _DateAdd('s', $iTime, $dtRes) Return $dtRes EndFunc Link to comment Share on other sites More sharing options...
water Posted October 31, 2016 Share Posted October 31, 2016 Glad you liked the solution kctvt 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now