I would like to have last weeks Thursday date displayed in a msgbox... How can I do this?
VB Code: Dim my_date As Date my_date = Date 'get into the end of "last week" my_date = DateAdd("d", -Weekday(my_date), my_date) 'count backwards to thursday Do While Weekday(my_date) <> vbThursday my_date = DateAdd("d", -1, my_date) Loop 'show date MsgBox Format(my_date, "ddd d m yy")
Dim my_date As Date my_date = Date 'get into the end of "last week" my_date = DateAdd("d", -Weekday(my_date), my_date) 'count backwards to thursday Do While Weekday(my_date) <> vbThursday my_date = DateAdd("d", -1, my_date) Loop 'show date MsgBox Format(my_date, "ddd d m yy")
(Microsoft MVP from July 2007 to June 2017) . . . . . . . . . . Hitchhiker's Guide to Getting Help at VBForums Database Development FAQs/Tutorials (updated May 2011) (includes fixing common DB related errors, and [VB.Net] ADO.Net Tutorial, and [Classic VB] ADO tutorial /further steps) other useful DB bits: . Connection strings (alternative copy).•. MDAC/Jet/ACE downloads .•. SQL Server downloads . Classic VB FAQs (updated Oct 2010) (includes fixing common VB errors) some of my Classic VB bits: . Tutorial: How to automate Excel from VB6 (or VB5/VBA) .•. SQL 'Select' statement formatter/checker .•. Convert colour number to colour name .•. FlexGrid: fill from recordset .•. FlexGrid: AutoSize columns .•. DB Reserved Words checker .
Forum Rules