I need to get the DateValues of the last 30 days (starting from yesterday, not today!) excluding saturdays and sundays. I want that the dates are german time (GMT + 1). The only solution I have found so far is to download with FinancialData the share prices of a german company for the last 30 days, since stock exchanges are closed during weekends.

For example:

yesterday = Take[DateList @ Today, 3] /. {a__, b_} :> {a, b - 1}


{2015, 3, 30}

FinancialData["F:VOW", {{2015, 2, 28}, yesterday}][[All, 1]]


(F:VOW is a german share) gives the wanted result:

{{2015, 3, 2}, {2015, 3, 3}, {2015, 3, 4}, {2015, 3, 5}, {2015, 3,
6}, {2015, 3, 9}, {2015, 3, 10}, {2015, 3, 11}, {2015, 3, 12}, {2015, 3, 13}, {2015, 3, 16}, {2015, 3, 17}, {2015, 3, 18}, {2015, 3, 19}, {2015, 3, 20}, {2015, 3, 23}, {2015, 3, 24}, {2015, 3, 25}, {2015, 3, 26}, {2015, 3, 27}, {2015, 3, 30}}

But - because of the download of share prices which I don't need - my "solution" takes seconds and seconds.

Please speed this up for me

This is how you can get the last 30 weekdays starting from yesterday:

days = DayRange[DayPlus[Yesterday, -30], Yesterday, "Weekday"]


To get {y,m,d} vectors, we might use

Take[#, 3] &@*DateList /@ days


Regarding the time zone, the only problem I can see would be that Yesterday will not produce the right result around midnight. To check this I used the Spelunking package, which told me that Yesterday is implemented as

Yesterday := DateObject[Take[DateList[], 3] - {0, 0, 1}]


DateList uses the time zone that is set on the computer you are using, so if your computer is set to the German time zone then you are alright. If not you can define a new function just like the one above but with DateList[TimeZone -> 1] instead.

• great answer: It should be swedish or german time (gmt+1) only showing y,m,d – eldo Mar 31 '15 at 20:26
• I think Yesterday = DayPlus[DateList[], -1] for v9? – bobthechemist Mar 31 '15 at 20:29
• @bobthechemist That looks right; I've also added another alternative to the post. – C. E. Mar 31 '15 at 21:13
• @eldo I think I've resolved the time zone issue now, if I understand it correctly. – C. E. Mar 31 '15 at 21:14
• Yes,, you have,dear Pickett. Before I accept tomorrow I would like to understand the DayPlus-function, which is new to me. – eldo Mar 31 '15 at 21:28
Select[DayPlus[DateList[TimeZone -> 2], #] & /@
Range[-30, -1], (! DayMatchQ[#, "Weekend"] &)]


I live in Germany TimeZone -> 2 is the correct Timezone for summertime and in winter i goes you have to take TimeZone-> 1

If you run the Kernel from Germany

 $TimeZone  should always have the correct value (Summer and Wintertime) so i suggest to leave this Option out. • Thank you too, sacratus,. You have -$TimeZone - solved my concern about different time zones:: My PC is in Berlin, so my time zone is Berlin. – eldo Mar 31 '15 at 20:51
• @eldo np, from the docs of $TimeTone: $TimeZone is set at the beginning of your Mathematica session to the time zone specified by your computer operating system. So you dont have to think about this ;-) – sacratus Mar 31 '15 at 20:53