Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Want to get todays date - 1 day value  (Read 16158 times)

0 Members and 1 Guest are viewing this topic.

nbahari

    Topic Starter


    Starter

    Want to get todays date - 1 day value
    « on: July 01, 2008, 03:52:45 AM »
    hi...

    i know how to to current date value but i don know how to get a value of today's date minus 1 day.

    i wan to get yesterday's date.

    appreciate all yr help

    diablo416



      Hopeful
      • Experience: Beginner
      • OS: Unknown
      Re: Want to get todays date - 1 day value
      « Reply #1 on: July 01, 2008, 06:41:17 AM »
      use set /a

      set /a d=%d%-1

      Carbon Dudeoxide

      • Global Moderator

      • Mastermind
      • Thanked: 169
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Experience: Guru
      • OS: Mac OS
      Re: Want to get todays date - 1 day value
      « Reply #2 on: July 01, 2008, 06:54:08 AM »
      What's %d%?  ::)

      For me, echo %date% in Command Prompt is 01-Jul-08
      So... set /a d=%date:~0,2% would give me 01

      And then set /a yesterday=%d%-1 would give you yesterday's date.

      However, it will say 00 instead of 30  ???

      ghostdog74



        Specialist

        Thanked: 27
        Re: Want to get todays date - 1 day value
        « Reply #3 on: July 01, 2008, 07:00:16 AM »
        why are you guys using DOS to do date arithmetic ? Its time to move on

        @OP. Use the next better language that M$ provides you, out of the box
        Code: [Select]
        WScript.Echo DateAdd("d", -1, Now)

        save the above as yesterday.vbs on the command prompt
        Code: [Select]
        c:\test> cscript /nologo yesterday.vbs

        nbahari

          Topic Starter


          Starter

          Re: Want to get todays date - 1 day value
          « Reply #4 on: July 01, 2008, 08:13:15 PM »
          many thx for all yr respond.

          on the WScript thingy, u r saying it is out of box?  cant locate it in my PC/server. still on Win2000 & server is Win2003.

          nbahari

            Topic Starter


            Starter

            Re: Want to get todays date - 1 day value
            « Reply #5 on: July 01, 2008, 08:18:47 PM »
            sorry...  kindly ignore my earlier respond.  got it!

            again, many2 thx for your help.  now jez need to further improve on getting the information out of the result...