DigDeep Posted January 22, 2017 Share Posted January 22, 2017 I am able to get today's date in the MM/DD/YYYY format. But I also want to get Yesterday's date in the same format. I tried using _DateADD but that gives me result in the M/DD/YYYY format. Local $Today = _Date_Time_GetSystemTime() Local $CalDate = _Date_Time_SystemTimeToDateStr($Today) MsgBox(0, '', $CalDate) Local $Yesterday = _DateTimeFormat(_DateAdd('d', -1, _NowCalcDate()), 2) MsgBox(0, '', $Yesterday) Can someone check once? Link to comment Share on other sites More sharing options...
Danp2 Posted January 22, 2017 Share Posted January 22, 2017 (edited) . Edited January 22, 2017 by Danp2 Nevermind Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DigDeep Posted January 22, 2017 Author Share Posted January 22, 2017 (edited) Yes, I tried that too as stated above. Local $Yesterday = _DateAdd('d', -1, _NowCalcDate()) But that gives me in the YYYY/MM/DD format. I wanted to get the result in the MM/DD/YYYY format. I also tried to take the _DateAdd to convert it to my result as per below, but the code does not run. Local $Yesterday = _DateAdd('d', -1, _NowCalcDate()) Local $Yesterday1 = $Yesterday[1] & "/" & $Yesterday[2] & "/" & $Yesterday[0] MsgBox(0, '', $Yesterday) Edited January 22, 2017 by DigDeep Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 22, 2017 Moderators Share Posted January 22, 2017 DigDeep, #include "Date.au3" Local $Today = _Date_Time_GetSystemTime() Local $CalDate = _Date_Time_SystemTimeToDateStr($Today) MsgBox(0, '', $CalDate) Local $Yesterday = _DateTimeFormat(_DateAdd('d', -1, _NowCalcDate()), 2) ; Split DTG $aYesterday = StringSplit($Yesterday, "/") ; Reassemble in desired order $sYesterdayFormatted = $aYesterday[2] & "/" & $aYesterday[1] & "/" & $aYesterday[3] MsgBox(0, '', $Yesterday & @CRLF & $sYesterdayFormatted) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DigDeep Posted January 22, 2017 Author Share Posted January 22, 2017 Thanks @Melba23. I just modified it a little bit and got it. ;~ Local $Yesterday = _DateTimeFormat(_DateAdd('d', -1, _NowCalcDate()), 2) Local $Yesterday = _DateAdd('d', -1, _NowCalcDate()) ; Split DTG $aYesterday = StringSplit($Yesterday, "/") ; Reassemble in desired order $sYesterdayFormatted = $aYesterday[2] & "/" & $aYesterday[3] & "/" & $aYesterday[1] MsgBox(0, '', $Yesterday & @CRLF & $sYesterdayFormatted) Link to comment Share on other sites More sharing options...
Gianni Posted January 22, 2017 Share Posted January 22, 2017 ... have also a look to the _DateTimeSplit() function #include <date.au3> Local $aDatePart ; will receive the date splitted in [1] year, [2] month, [3] day Local $aTimePart ; not used here Local $Yesterday = _DateAdd('d', -1, _NowCalcDate()) Local $x = _DateTimeSplit($Yesterday, $aDatePart, $aTimePart) Local $Yesterday1 = $aDatePart[2] & "/" & $aDatePart[3] & "/" & $aDatePart[1] MsgBox(0, '', $Yesterday1) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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