Results 1 to 9 of 9

Thread: set date to route

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2016
    Posts
    195

    set date to route

    I try to put this


    PrinterFilePath = App.Path & "\ventas" & format(now()) & ".pdf"


    The dialog box to save pdf appears

    The name of the file plus the date and the pdf extension should appear.

    thank you
    Attached Files Attached Files

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,750

    Re: set date to route

    Check what format(now())) shows on your system.
    A filename cannot contain the following characters
    Code:
     \ / : * ? " < > |

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,153

    Re: set date to route

    "Now" returns the Date incl. Time in local Format.
    If the local Format has "forbidden" Characters, your code should fail.
    Nevermind that you use the Format-Function WITHOUT a defined Format

    Code:
    PrinterFilePath = App.Path & "\ventas" & format(Date, "YYYY-MM-DD") & ".pdf"
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  4. #4
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,644

    Re: set date to route

    I use

    Filename = sys.Shot & VBA.Format(Now, "yyyy.mm.dd.hh.mm.ss") & Target.Ext(mode)

    for my "screenshot" filename. since I can use multiple formats and u can click fast I also use h/m/s

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2016
    Posts
    195

    Re: set date to route

    resolved

    Code:
    PrinterFilePath = App.Path & "\ventas pdf\ventas" & Format(Now, "dd-mm-YYYY-hh-mm-ss") & ".pdf"

    thank you so much

  6. #6
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,153

    Re: set date to route

    Quote Originally Posted by ontro View Post
    resolved

    Code:
    PrinterFilePath = App.Path & "\ventas pdf\ventas" & Format(Now, "dd-mm-YYYY-hh-mm-ss") & ".pdf"

    thank you so much
    Don't use this format
    Your sorting inside File-Explorer will not be what you expect

    rather
    Code:
    PrinterFilePath = App.Path & "\ventas pdf\ventas" & Format(Now, "YYYY-MM-DD hh-nn-ss") & ".pdf"
    Note the BLANK/Space between Date and Time

    And look very closely what i use in the Format-String for minutes (yes, the "mm" is valid, but look at the caveats)
    https://learn.microsoft.com/en-us/of...r-applications
    Last edited by Zvoni; Sep 21st, 2023 at 08:51 AM.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2016
    Posts
    195

    Re: set date to route

    thank you Zvoni

  8. #8
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,644

    Re: set date to route

    Zvoni no, its depends on the system. not everyone uses yyyy-mm-dd some uses dd-mm-yyyy
    also avoid upper case.
    and its about taste. u do not need space, u can use whatever.
    not all time-formats uses what the fileexplorer uses.

  9. #9
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,895

    Re: set date to route

    Quote Originally Posted by baka View Post
    Zvoni no, its depends on the system. not everyone uses yyyy-mm-dd some uses dd-mm-yyyy
    also avoid upper case.
    and its about taste. u do not need space, u can use whatever.
    not all time-formats uses what the fileexplorer uses.
    Zvoni's point was that if you use dd-mm-yyyy buried inside the filename, then Explorer will not sort the files chronologically when sorted by name.

Posting Permissions

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



Click Here to Expand Forum to Full Width