Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hours & Minutes (XP)

    I am in the process of trying to obtain the hours and minutes from these lines of code and am having difficulty.

    I can return the Year, Month and Day but the challenge is the Hours and Minutes.

    Your assistance is appreciated.
    John

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hours & Minutes (XP)

    There are a number of these BATch file 'functions' around. Yours looks uncannily similar to those by Ritchie Lawrence!

    If you can understand the workings of the one you've got, try this one:<pre>:: generalised DATE and TIME routine for NT4/W2K/WXP and all Regional Settings
    :: %yy% will contain four digits, 20nn;
    :: %mm%, %dd% and time variables %hr%, %mn%, %sc% and %th% contain two digits
    if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
    for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo.^|date') do (
    for /f "tokens=%toks% delims=.-/ " %%e in ('date /t') do (
    for /f "tokens=5-8 delims=:., " %%i in ('echo.^|time') do (
    (set %%a=%%e) & (set %%b=%%f) & (set %%c=%%g) & rem create yy, mm, dd
    (set hr=%%i) & (set mn=%%j) & (set sc=%%k) & (set th=%%l)
    rem note the variable names for Time: hr, mn, sc, th
    )))
    if 1%yy% LSS 200 (set yy=20%yy%) & :: ensure 4-digit years in %yy%
    if 1%hr% LSS 20 (set hr=0%hr%) & :: ensure 2-digit hours in %hr%

    echo Date is: %yy%-%mm%-%dd% Time is: %hr%:%mn%:%sc%.%th%</pre>

    Given my code, you ought to be able to modify yours, I would hope...

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  4. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hours & Minutes (XP)

    John,

    After a while most of the code looks similar. Although I would certainly would want to give credit to the individual who created it.

    I am testing your code and am sure it will work with what I am trying to accomplish.

    Many thanks, <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>
    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •