snipt

Ctrl+h for KB shortcuts

VB.net

VBScript – Aktuelle Kalenderwoche

1
2
3
4
5
Function KW(myDate) 
Dim t
	t = DateSerial(Year(myDate + (8 - Weekday(myDate)) Mod 7 - 3), 1, 1)
	KW = (myDate - t - 3 + (Weekday(t) + 1) Mod 7) \ 7 + 1
End Function
https://snipt.net/embed/3e4a6debfa54dad54189524d55b9f2b4/
/raw/3e4a6debfa54dad54189524d55b9f2b4/
3e4a6debfa54dad54189524d55b9f2b4
vb.net
VB.net
5
2019-07-19T18:59:38
True
False
False
/api/public/snipt/49226/
vbscript-aktuelle-kalenderwoche
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">Function</span> <span class="nf">KW</span><span class="p">(</span><span class="n">myDate</span><span class="p">)</span> </span><span id="L-2"><a name="L-2"></a><span class="k">Dim</span> <span class="n">t</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">t</span> <span class="o">=</span> <span class="n">DateSerial</span><span class="p">(</span><span class="n">Year</span><span class="p">(</span><span class="n">myDate</span> <span class="o">+</span> <span class="p">(</span><span class="mi">8</span> <span class="o">-</span> <span class="n">Weekday</span><span class="p">(</span><span class="n">myDate</span><span class="p">))</span> <span class="ow">Mod</span> <span class="mi">7</span> <span class="o">-</span> <span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">KW</span> <span class="o">=</span> <span class="p">(</span><span class="n">myDate</span> <span class="o">-</span> <span class="n">t</span> <span class="o">-</span> <span class="mi">3</span> <span class="o">+</span> <span class="p">(</span><span class="n">Weekday</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="ow">Mod</span> <span class="mi">7</span><span class="p">)</span> <span class="o">\</span> <span class="mi">7</span> <span class="o">+</span> <span class="mi">1</span> </span><span id="L-5"><a name="L-5"></a><span class="k">End</span> <span class="k">Function</span> </span></pre></div> </td></tr></table>
date, vbscript