Sign in to follow this  
Followers 0
mattschinkel

get all dates of days this week

3 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by whim

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0