Announcement

Collapse
No announcement yet.

WeekDayName today - VBS

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • WeekDayName today - VBS

    I'm trying to use the "WeekDayName" function in Visual Basic Script to return the day of the week. Unfortunately it doesn't seem to like the way I'm passing the parameter it needs (the Date).

    This works:

    dtmThisDay = WeekdayName(Day("04/10/2007"))

    but this doesn't:
    dtmThisDay = WeekdayName(Day(Date))

    (I want the script to evaluate the day of the week when it's run rather than passing today's date to it...)

    Anyone any ideas how to fix it? I've tried putting quotes around "Date" but then I get a type mismatch error because it doesn't parse "Date" as a function it parses it as text, and I've tried putting quotes round "(Date)" and it then complains because it expects a bracket and finds a quote...

    Thanks in advance


    Tom
    For my own and your protection, I do not provide support by private message under any circumstances. All such messages will be deleted and ignored.

    Anything you say will be misquoted and used against you

  • #2
    Re: WeekDayName today - VBS

    How about something like
    Day(cstr(Date))

    i.e. force the date into a string format before applying the day function?

    Tom
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: WeekDayName today - VBS

      Originally posted by Ossian View Post
      How about something like
      Day(cstr(Date))

      i.e. force the date into a string format before applying the day function?

      Tom
      "Invalid Procedure call or argument (WeekDayName)"

      This is the same error I first got...


      Tom
      For my own and your protection, I do not provide support by private message under any circumstances. All such messages will be deleted and ignored.

      Anything you say will be misquoted and used against you

      Comment


      • #4
        Re: WeekDayName today - VBS

        Use Weekday(), not Day().

        Day() returns the day of the month.

        EDIT: Example:

        Code:
        dtmThisDay = WeekdayName(Weekday(Date))
        Last edited by rvalstar; 10th April 2007, 11:12.
        Cheers,

        Rick

        ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

        2006-2099 R Valstar. This post is offered "as is" for discussion purposes only with no express or implied warranty of any kind including, but not limited to, correctness or fitness for use. Nothing herein shall be construed as advice. Attempting any activity based on information in this post is done at your own risk.

        Comment


        • #5
          Re: WeekDayName today - VBS

          OK... so why does

          dtmThisDay = WeekdayName(Day("04/10/2007"))

          work?


          Tom
          For my own and your protection, I do not provide support by private message under any circumstances. All such messages will be deleted and ignored.

          Anything you say will be misquoted and used against you

          Comment


          • #6
            Re: WeekDayName today - VBS

            What does MsgBox(Day("04/10/2007")) give you? 4 because you use UK Regionalization and it thinks that's 4 October? Thus WeekdayName gives Wednesday vs. Tuesday?

            I get 10 (April) w/ USA Regionalization and that bombs. So it will work (incorrectly) for the first 7 days of the month.
            Cheers,

            Rick

            ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

            2006-2099 R Valstar. This post is offered "as is" for discussion purposes only with no express or implied warranty of any kind including, but not limited to, correctness or fitness for use. Nothing herein shall be construed as advice. Attempting any activity based on information in this post is done at your own risk.

            Comment


            • #7
              Re: WeekDayName today - VBS

              Originally posted by rvalstar View Post
              What does MsgBox(Day("04/10/2007")) give you? 4 because you use UK Regionalization and it thinks that's 4 October? Thus WeekdayName gives Wednesday vs. Tuesday?

              I get 10 (April) w/ USA Regionalization and that bombs. So it will work (incorrectly) for the first 7 days of the month.
              LOL yeah except the 4th Oct this year is a THURSDAY...?! So yes, it gave me Wednesday but I was going to look at this as another error. As it happens, your fix worked beautifully... and my script is now working.

              Thank you!


              Tom
              For my own and your protection, I do not provide support by private message under any circumstances. All such messages will be deleted and ignored.

              Anything you say will be misquoted and used against you

              Comment

              Working...
              X