guinness Posted February 16, 2011 Share Posted February 16, 2011 (edited) Working Code has been Included!More details about the WMI Date String can be found here >> http://technet.microsoft.com/en-us/library/ee156576.aspxThere is currently an Example of WMIDateStringToDate() floating around the Forums that uses StringMid() but I decided that I wanted to have a little go at improving my knowledge of StringRegExpReplace(). Therefore I created the following Functions with thanks to jhcd, PsaltyDS & GEOSoft >>Function:expandcollapse popup; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #FUNCTION# ========================================================================================================= ; Name...........: _WMIDateStringToDate() ; Description ...: Converts a WMI date to a UK/US formatted date. ; Syntax.........: _WMIDateStringToDate($sDate) ; Parameters ....: $sDate - A WMI returned from an Object() call. ; Requirement(s).: v3.2.12.1 or higher ; Return values .: Success - A UK/US formatted date. ; Failure - Returns 0 ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _WMIDateStringToDate($sDate) Local $sDelimeter = '/' Return StringRegExpReplace($sDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.\d{6}\+\d{3}', '\3' & $sDelimeter & '\2' & $sDelimeter & '\1 \4:\5:\6') ; jchd's Efficent Version - $10 Is The Number Of Minutes Difference Between Your Local Time And Greenwich Mean Time. EndFunc ;==>_WMIDateStringToDate ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #FUNCTION# ========================================================================================================= ; Name...........: _DateToWMIDateString() ; Description ...: Converts a UK/US formatted date to WMI date. ; Syntax.........: _DateToWMIDateString($sDate) ; Parameters ....: $sDate - A UK/US formatted date. ; Requirement(s).: v3.2.12.1 or higher ; Return values .: Success - A WMI date. ; Failure - Returns 0 ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _DateToWMIDateString($sDate) Local $iOffSet = 000, $oWMIService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\.\root\cimv2') Local $oColFiles = $oWMIService.ExecQuery('Select Bias From Win32_TimeZone') If IsObj($oColFiles) Then For $oObjectFile In $oColFiles $iOffSet = $oObjectFile.Bias ; Retrieve GMT Offset - http://technet.microsoft.com/en-us/library/ee156558.aspx Next EndIf Return StringRegExpReplace($sDate, '(\d{2})/(\d{2})/(\d{4})\s+(\d{2}):(\d{2}):(\d{2})', '\3\2\1\4\5\6.000000+') & $iOffSet ; jchd's Version. EndFunc ;==>_DateToWMIDateString ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #FUNCTION# ========================================================================================================= ; Name...........: _WMIDateStringToDateLocale() ; Description ...: Converts a WMI date to a UK/US formatted date depending on your regional settings. ; Syntax.........: _WMIDateStringToDateLocale($sDate) ; Parameters ....: $sDate - A WMI returned from an Object() call. ; Requirement(s).: v3.2.12.1 or higher ; Return values .: Success - A UK/US formatted date. ; Failure - Returns 0 ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _WMIDateStringToDateLocale($sDate) Return _DateTimeFormat(StringRegExpReplace($sDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.\d{6}\+\d{3}', '\1/\2/\3 \4:\5:\6'), 0) EndFunc ;==>_WMIDateStringToDateLocaleExample use of Function:#include <Constants.au3> #include <Date.au3> Local $sDate = _DateToWMIDateString(@MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC) ; Get Todays Date & Time (01/12/2011 12:01:59) MsgBox($MB_SYSTEMMODAL, '_DateToWMIDateString()', $sDate) ; Example of converting 01/12/2011 12:01:59 >> 20111201120159.000000+000 MsgBox($MB_SYSTEMMODAL, '_WMIDateStringToDate()', _WMIDateStringToDate($sDate)) ; Example of converting 20111201120159.000000+000 >> 01/12/2011 12:01:59Edit: Updated with responses from below Edited June 30, 2014 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 16, 2011 Share Posted February 16, 2011 (edited) You might want to look at in the Example Scripts, at the change log in the first post: 06/12/2008 -- v2.0.1 -- Added geeky RegExp for WMI date conversion by weaponxHere was the /page__view__findpost__p__534828. Edited February 16, 2011 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
jchd Posted February 16, 2011 Share Posted February 16, 2011 I'd do this (several typos fixed): Global $Date = _DateToWMIDateString(@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) ; Get Todays Date & Time (01/12/2011 12:01:59) MsgBox(64, "_DateToWMIDateString()", $Date) ; Example of converting 01/12/2011 12:01:59 >> 20111201120159.00000+000 MsgBox(64, "_WMIDateStringToDate()", _WMIDateStringToDate($Date)) ; Example of converting 20111201120159.00000+000 >> 01/12/2011 12:01:59 Func _WMIDateStringToDate($sDate) ; Converts "20111201120159.00000+000" >> "01/12/2011 12:01:59" Return StringRegExpReplace($sDate, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.\d{5}\+\d{3}", "$3/$2/$1 $4:$5:$6") EndFunc ;==>_WMIDateStringToDate Func _DateToWMIDateString($sDate) ; Converts "01/12/2011 12:01:59" >> "20111201120159.00000+000" Local $iOffSet = 000 Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColFiles = $oWMIService.ExecQuery("Select * From Win32_TimeZone") If IsObj($oColFiles) Then For $oObjectFile In $oColFiles $iOffSet = $oObjectFile.Bias ; Retrieve GMT Offset - http://technet.microsoft.com/en-us/library/ee156558.aspx Next EndIf Return StringRegExpReplace($sDate, "(\d{2})/(\d{2})/(\d{4})\h+(\d{2}):(\d{2}):(\d{2})", "$3$2$1$4$5$6.000000+") & $iOffSet EndFunc ;==>_DateToWMIDateString Disclaimer: I didn't test it! This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
guinness Posted February 16, 2011 Author Share Posted February 16, 2011 (edited) Argh! Silly mistakes in my First Post! Thanks jchd for pointing them out. I tested yours and it seems your version of _WMIDateStringToDate() doesn't work for some reason, whereas mine did. And thanks for the alternative with _DateToWMIDateString() (there are more ways to peal a banana - PC version of an old idiom!)PsaltyDS - Thanks for that, I didn't search about this to be honest (not like me) but then my script worked, I was just looking at other variations of doing the same thing. As you said in the _ProcessListProperties() post >> "Constructive criticism welcome." << Always felt this emoticon looks as though it's confused and not winking!I hope no one minds me using the General Forum to ask about this?! Edited February 16, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jchd Posted February 16, 2011 Share Posted February 16, 2011 Ooops against Ooops: we've both made errors. _WMIDateStringToDate() does work on the supplied example _DateToWMIDateString() doesn't due to \h+ used in place of \s+ so the last line should be Return StringRegExpReplace($sDate, "(\d{2})/(\d{2})/(\d{4})\s+(\d{2}):(\d{2}):(\d{2})", "$3$2$1$4$5$6.000000+") & $iOffSet Also you might want to use StringFormat to make sure that $iOffset has leading zero(es). This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
guinness Posted February 16, 2011 Author Share Posted February 16, 2011 (edited) Cool thanks for that, but i don't know how you are getting your version of _WMIDateStringToDate() to work? As it should be this >> Return StringRegExpReplace($sDate, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.\d{6}\+\d{3}", "$3/$2/$1 $4:$5:$6") \d{5} was changed to \d{6} Edited February 16, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jchd Posted February 16, 2011 Share Posted February 16, 2011 I changed it from 6 to 5 digits to follow the [only] example _you_ gave This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
guinness Posted February 16, 2011 Author Share Posted February 16, 2011 (edited) Yes...You're right, I'm sorry about that , was in a rush whilst typing the Example comments. So I was in the wrong this time ... Touché Touché! Edited February 16, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jchd Posted February 16, 2011 Share Posted February 16, 2011 No harm done, we all make dumb mistakes by the yard, don't we? Indeed I was expecting you to catch this as I thought you successfully tested your code, so I was about positive it should have been \d{6}, but the accompanying example was .00000+000 so I sticked to it. If only every error could be so elementary in all software industry! This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
GEOSoft Posted February 17, 2011 Share Posted February 17, 2011 One of these days I have to get some time to take the WMI date code out og my compiled version of the Scripto-matic. I wrote a function to do exactly what you needed that uses a simple DLL call with StringFormat() that I was going to put in there instead. It returned the correct results and it wasn't as convoluted as the existing WMIDateStringToDate() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
argumentum Posted May 18, 2015 Share Posted May 18, 2015 plaese help me with this regular expression stuff#include <Constants.au3> #include <Date.au3> Local $sDate = @MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC ; Get Todays Date & Time (01/12/2011 12:01:59) MsgBox($MB_SYSTEMMODAL, '_DateToWMIDateString()', $sDate & @CR & ' = ' & @CR & _DateToWMIDateString($sDate)) ; Example of converting 01/12/2011 12:01:59 >> 20111201120159.000000+000 MsgBox($MB_SYSTEMMODAL, '_WMIDateStringToDate()', _DateToWMIDateString($sDate) & @CR & ' = ' & @CR & _WMIDateStringToDate(_DateToWMIDateString($sDate))) ; Example of converting 20111201120159.000000+000 >> 01/12/2011 12:01:59 MsgBox($MB_SYSTEMMODAL, '_WMIDateStringToDateLocale()', _DateToWMIDateString($sDate) & @CR & ' = ' & @CR & _WMIDateStringToDate(_DateToWMIDateString($sDate)))it don't work for me Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
iamtheky Posted May 18, 2015 Share Posted May 18, 2015 I think that regexp is only checking for + signs, but i may be wrong. This clears it up: Func _WMIDateStringToDate($sDate) Local $sDelimeter = '/' Return StringRegExpReplace($sDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.\d{6}(\+|\-)\d{3}', '\3' & $sDelimeter & '\2' & $sDelimeter & '\1 \4:\5:\6') ; jchd's Efficent Version - $10 Is The Number Of Minutes Difference Between Your Local Time And Greenwich Mean Time. EndFunc ;==>_WMIDateStringToDate ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
kylomas Posted May 18, 2015 Share Posted May 18, 2015 argumentum,I use this function in a modified version of Scriptomatic that I use. Func CNVTDate($dtmDate) ; reformat date to mm/dd/yyyy hh:mm:ss and zero fill single digit values Return StringRegExpReplace(StringRegExpReplace($dtmDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).*', '$2/$3/$1 $4:$5:$6'), '(?<!\d)(\d/)', '0$1') EndFunc ;==>CNVTDateI also fixed the problem with WMI returning array's. PM me if your interested.kylomas argumentum 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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