1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Do UNTIL DATETIME date time

Discussion in 'Support' started by vefatica, May 30, 2010.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,971
    Likes Received:
    30
    The help says YYYY-MM-DD HH:MM:SS is OK but it doesn't work. I only get one iteration.

    Code:
    v:\> type dodo.bat
    echo on
    do until datetime 2010-06-01 00:00:00
            delay 1
    enddo
    
    v:\> dodo.bat
    do until datetime 2010-06-01 00:00:00
    delay 1
    
    v:\>
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,971
    Likes Received:
    30
    And when using a one-token datetime specification involving a variable function, the results are unpredictable. Below, the first two loops work and the third doesn't!

    Code:
    v:\> type dodo.bat
    do until datetime %@eval[%_datetime]
            echo %_time
            delay 1
    enddo
    echo Done!
    
    do until datetime %@eval[%_datetime+0]
            echo %_time
            delay 1
    enddo
    echo Done!
    
    do until datetime %@eval[%_datetime+1]
            echo %_time
            delay 1
    enddo
    echo Done!
    
    v:\> dodo.bat
    17:39:08
    Done!
    17:39:09
    Done!
    17:39:10
    17:39:11
    17:39:12
    17:39:13
    17:39:14
    17:39:15
    17:39:16
    ^C
    
    v:\>
     
  3. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ----- Original Message -----
    From: "vefatica" <>
    To: <ESFabian@comcast.net>
    Sent: 2010. May 30., Sunday 17.44
    Subject: RE: [Support-t-2007] Re: Do UNTIL DATETIME date time



    Vince,
    the value of @eval is a floating point number that happens to be an integer,
    but not a true "datetime" until its value is converted into a decimal
    integer format. Due to its history TCC does not make the sharp distinction
    between numeric types and strings that other HLLs do. Did you try to force
    the function result into the datetime format?
    --
    Steve
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,971
    Likes Received:
    30
    On Sun, 30 May 2010 18:08:16 -0400, Steve Fábián <> wrote:

    |Vince,
    |the value of @eval is a floating point number that happens to be an integer,
    |but not a true "datetime" until its value is converted into a decimal
    |integer format. Due to its history TCC does not make the sharp distinction
    |between numeric types and strings that other HLLs do. Did you try to force
    |the function result into the datetime format?

    Steve, @EVAL[] produces a **string**, exactly what's called for.

    v:\> echo %_datetime^r^n%@eval[%_datetime+1]
    20100530192246
    20100530192247
    --
    - Vince
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,971
    Likes Received:
    30
    Did anyone confirm that it's broken?

    Code:
    v:\> type dodo.bat & echo Now: %_date %_time^r^n^r^n & dodo.bat
    do until datetime 2010-06-03 10:46:00
            echo %_time
            delay 1
    enddo
    echo Batchfile done.
    
    Now: 2010-06-03 10:45:50
    
    
    10:45:50
    Batchfile done.
     
  6. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    604
    Likes Received:
    0
    It appears broken on my machine using MM-DD HH:MM:SS but works as
    advertised using YYYYMMDDHHMMSS

    .) Works using compressed time format
    D:\>type test.btm %+ echo %_date %_time %+ test.btm
    do until datetime 20100603081420
    echo %_time
    delay 1
    enddo
    echo Batchfile done.
    2010-06-03 08:14:16
    08:14:16
    08:14:17
    08:14:18
    08:14:19
    Batchfile done.

    .) Fails using expanded time format
    D:\>type test.btm %+ echo %_date %_time %+ test.btm
    do until datetime 2010-06-03 08:15:00
    echo %_time
    delay 1
    enddo
    echo Batchfile done.
    2010-06-03 08:14:49
    08:14:49
    Batchfile done.

    D:\>
    On Thu, Jun 3, 2010 at 7:47 AM, vefatica <> wrote:




    --
    Jim Cook
    2010 Sundays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Monday.
     
  7. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,312
    Likes Received:
    39
    I see the opposite: Using YYYY-MM-DD HH:MM:SS, the appointed time comes and goes, and the loop she just keeps right on a-loopin'.

    The compressed format does work as expected.
     

Share This Page