mattschinkel Posted January 21, 2011 Share Posted January 21, 2011 How can I get the dates of all days this week into an array? sunday to saturday, in format YYY/MM/DD I searched the forums and only found week number and day of week by date. Thanks, Matt. Link to comment Share on other sites More sharing options...
whim Posted January 21, 2011 Share Posted January 21, 2011 (edited) Hi, try this: #include <Date.au3> #include <Array.au3> Global $this_week[7] For $i = 0 To 6 $this_week[$i] = _DateAdd("D", $i + 1 - @WDAY, _NowCalcDate()) Next ; option: add " <--" to indicate today $this_week[@WDAY-1] &= " <--" _ArrayDisplay($this_week) edit: or this, if you want the weekdays shown as well #include <Date.au3> #include <Array.au3> Global $this_week[7][2] = [ ["", "Sun"], ["", "Mon"], ["", "Tue"], ["", "Wed"], ["", "Thu"], ["", "Fri"], ["", "Sat"] ] For $i = 0 To 6 $this_week[$i][0] = _DateAdd("D", $i + 1 - @WDAY, _NowCalcDate()) Next $this_week[@WDAY-1][1] &= " <--" ; optionally add " <--" to indicate today _ArrayDisplay($this_week) (tested on 3.3.6.1 / Win 7) Edited January 21, 2011 by whim Link to comment Share on other sites More sharing options...
mattschinkel Posted January 21, 2011 Author Share Posted January 21, 2011 Hi, try this: #include <Date.au3> #include <Array.au3> Global $this_week[7] For $i = 0 To 6 $this_week[$i] = _DateAdd("D", $i + 1 - @WDAY, _NowCalcDate()) Next ; option: add " <--" to indicate today $this_week[@WDAY-1] &= " <--" _ArrayDisplay($this_week) (tested on 3.3.6.1 / Win 7) Your awesome, thanks! 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