[VBS] - Find last Thursday of Current Month - [VBS]

Discussion in 'Software' started by cmonney, Apr 4, 2005.

  1. cmonney

    cmonney Private E-2

    Hi,

    I was wondering if someone can show me a way to "Find the Last Thursday of the Current Month" using VBScript.

    Thanks In Advance!

    -cmonney
     
  2. Freddy

    Freddy Sergeant

    You could try an interative test against of each day in the month using the WeekDay function. In VBA its Weekday(CurrentDate) = 5 on Thursdays.
     
  3. cmonney

    cmonney Private E-2

    something like this :confused: ?

    Code:
    Dim currentMonth, nextMonth, MyDate
    
    currentMonth = Month(Date)
    nextMonth = Month(DateAdd("W", 1, Date))
    
    'LTM = Last Thursday Of The Month
    LTM = DateAdd("W", -1, DateSerial(Year(Date), sCtr(nextMonth), 1)
    
    While (WeekDay(LTM) <> VBThursday)
       FTM = FTM -1
    Wend
    
    msgBox LTM & "is the last Thursday of the current month!"
    
    thanks for your help!!!

    Regards,

    C$
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds