Results 1 to 33 of 33

Thread: [RESOLVED] how to create a monthly folder automatically

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Resolved [RESOLVED] how to create a monthly folder automatically

    I have a monthly function here.

    What would it be like to create a folder for each month?
    I mean end of the month create a new folder

    day 31-01-2024 create a new folder that says 01-02-2024



    Code:
    Private Function SetDates (pDate As Date) As String
     Select Case Month (pDate)
      Case 1, 3, 5, 7, 8, 10, 12
       SetDates = “31”
      Case 4, 6, 9, 11
       SetDates = “30”
      Case 2
       If (Year(pDate) Mod 4) = 0 Then
        SetDates = “29”
       Else
        SetDates = “28”
       End If
     End Select
    End Function

    thank you

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,496

    Re: how to create a monthly folder automatically

    Just an idea:
    Code:
    ' Return a foldername DD-MM-YYYY if the given date is the last day of the month
    ' otherwise return ""
    Private Function pFolderName(ByVal lDate As Long) As String
      If pIsLastDayOfMonth(lDate) Then pFolderName = Format(lDate + 1, "DD\-MM\-YYYY")
    End Function
    
    ' Check if the given date is the last day of the month
    Private Function pIsLastDayOfMonth(ByVal lDate As Long) As Boolean
      pIsLastDayOfMonth = (Day(lDate + 1) = 1)
    End Function

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: how to create a monthly folder automatically

    thank you

    to activate the functions as would be

    thank you

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: how to create a monthly folder automatically

    Code:
    ' Return a foldername DD-MM-YYYY if the given date is the last day of the month
    ' otherwise return ""
    Private Function pFolderName(ByVal lDate As Long) As String
      If pIsLastDayOfMonth(lDate) Then pFolderName = Format(lDate + 1, "DD\-MM\-YYYY")
    End Function
    
    ' Check if the given date is the last day of the month
    Private Function pIsLastDayOfMonth(ByVal lDate As Long) As Boolean
      pIsLastDayOfMonth = (Day(lDate + 1) = 1)
    End Function
    
    
    
    to create a folder
    
    
    
    Private Sub Command1_Click()
    Dim createfolder As Object
    Dim name As String
    Dim route As String
    
    route = App.Path & "\"
    name = InputBox("enter the name of a folder", "folder name")
    
    Set createfolder = CreateObject("scripting.filesystemobject")
    createfolder.createfolder route & name
    
    MsgBox "Your folder has been created successfully", vbInformation, "created folder"
    
    End Sub

    How to make the two functions work to make a folder

    day 31-01-2024 create a new folder that says 01-02-2024

    thank you

  5. #5
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,365

    Question Re: how to create a monthly folder automatically

    This code adds one day to the current date:

    Code:
    DateAdd("d", 1, Date)
    Then you can make a folder with "MkDir". Can you put them together?

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,799

    Re: how to create a monthly folder automatically

    Just as a tip, the easiest way to get the "last day of the month" is to create a date that's the first day of the next month, and then subtract one (day). That way, you let Windows (or VB6) deal with all the leap year stuff and how many days in each month.

    And just in case you didn't get MSDN installed. Here are most of the relevant VB6 functions you'll need:
    • DateValue
    • DateSerial
    • DateDiff
    • DateAdd
    • Year
    • Month
    • Day
    Last edited by Elroy; May 21st, 2024 at 10:14 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: how to create a monthly folder automatically

    hello

    I need the first day of each month and year

    I mean


    01-01-2024 create folder

    01-02-2024 create folder

    01-03-2024 create folder


    01.04-2024 create folder

    etc,etc

    thank you

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,799

    Re: how to create a monthly folder automatically

    Quote Originally Posted by ontro View Post
    hello

    I need the first day of each month and year

    I mean


    01-01-2024 create folder

    01-02-2024 create folder

    01-03-2024 create folder


    01.04-2024 create folder

    etc,etc

    thank you
    So, what problem are you having doing that?
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,026

    Re: how to create a monthly folder automatically

    Quote Originally Posted by Elroy View Post
    Just as a tip, the easiest way to get the "last day of the month" is to create a date that's the first day of the next month, and then subtract one (day). That way, you let Windows (or VB6) deal with all the leap year stuff and how many days in each month.
    Or look in Codebank, since we had a "new" LastDayOfMonth just a few weeks ago.

    Or you just use DateSerial on the "zero"-th Day of the following month....
    Code:
        Debug.Print DateSerial(2024, 6, 0)
    Returns: 2024-05-31

    And nevermind OP should use ISO-Format for the Foldernames.... "YYYY-MM-DD Blablab"
    Otherwise he'll get a surprise when sorting the Foldernames...

    btw: Why not just create all Folders for the Year in one go, and be done with it? No need for checking if it's the last Day of the Month and whatnot

    And instead of MkDir and/or using FSO, i'd rather go for SHCreateFolderExW-API, since that one uses absolute paths and creates any missing intermediate Folders, too
    If the Folder already exists, it's a No-Op
    Last edited by Zvoni; May 22nd, 2024 at 02:16 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

  10. #10
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,118

    Re: how to create a monthly folder automatically

    Quote Originally Posted by Zvoni View Post

    btw: Why not just create all Folders for the Year in one go, and be done with it? No need for checking if it's the last Day of the Month and whatnot
    thats what I would also do

    @ontro
    here a sample you can adjust to your needs
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
      Dim nYear As Long
            Dim nMonth As Long
            Dim nDays As Long
            Dim LastDayOfMonth As Date
            Dim FirstDayOfMonth As Date
            Dim d As Date
            
            
            For nYear = 2024 To 2026 'set Year or Years to create Folders
                For nMonth = 1 To 12
                   
                    LastDayOfMonth = DateSerial(nYear, nMonth + 1, 0)
                    FirstDayOfMonth = DateSerial(nYear, nMonth, 1)
                    
                    'get a Day count in that month
                    d = DateSerial(nYear, nMonth, 1)
                    nDays = Day(DateAdd("m", 1, d) - 1)
                
                    List1.AddItem ("First Day Of Month : " & Format(FirstDayOfMonth, "dddd dd.MM.yyyy"))
                    List1.AddItem ("Days in Month : " & nDays)
                    List1.AddItem ("Last Day of Month  : " & Format(LastDayOfMonth, "dddd dd.MM.yyyy"))
                    List1.AddItem ("---------------------------------------------------------------------")
    
         FolderCreateNew "E:\TestFolder\Reports\" & nYear & "\" & Format(FirstDayOfMonth, "dd-MM-yyyy") & "  " & Format(LastDayOfMonth, "dd-MM-yyyy"), True
    'create folders like:
    'E:\TestFolder\Reports\2024\01-01-2024 31-01-2024
    'E:\TestFolder\Reports\2024\01-02-2024 29-02-2024
    'etc...
    
    
                Next nMonth
            Next nYear
    End Sub
    
    Public Function FolderCreateNew(Path As String, _
                                 Optional ShowError As Boolean = True) As Boolean
       Dim s As String
       Dim s1() As String
       Dim s2 As String
       Dim Titel As String
       Dim i As Long
       
          Titel = "FolderCreate"
       
          
          If Len(Trim(Path)) = 0 Then
             If ShowError Then
                yourError 1, "no path text", Titel
             End If
             Exit Function
          End If
          s = Replace(Trim(Path), "\\", "\")
          'remove last BackSlash
          If Right(s, 1) = "\" Then
             s = Left$(s, Len(s) - 1)
          End If
          
          'split into Folders
          s1() = Split(s, "\")
          
          'does the Path exist
          s2 = Join(s1(), "\")
          If Len(Dir(s2, vbDirectory)) > 0 Then
             If ShowError Then
                yourError 2, "Path " & Path & vbCrLf & _
                              "exist allready", Titel
             End If
             Exit Function
          End If
          
          s2 = s1(LBound(s1))
          'check for Drive
          If Len(Dir(s2)) = 0 Then
             If ShowError Then
                yourError 3, "Drive " & s2 & " not found !", Titel
             End If
             Exit Function
          End If
          
          'check the Path(s)
          On Error GoTo Fehler
          For i = LBound(s1) + 1 To UBound(s1)
             s2 = s2 & "\" & s1(i)
             If Len(Dir(s2, vbDirectory)) = 0 Then
                'Folder doesn't exsit, so create it
                MkDir s2
             End If
          Next
          FolderCreateNew = True
          Exit Function
    Fehler:
          If ShowError Then
             yourError err.Number, err.Description, Titel
          End If
    End Function
    
    Public Sub yourError(ErrNumber As Long, ErrDescription As String, _
                             Optional Titel As String = "")
    
       Dim Msg As String
       
          Msg = "Error " & ErrNumber & vbCrLf & vbCrLf & _
                ErrDescription
          MsgBox Msg, vbCritical, Titel
    End Sub
    Last edited by ChrisE; May 22nd, 2024 at 04:17 AM.
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  11. #11
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,026

    Re: how to create a monthly folder automatically

    Quote Originally Posted by ChrisE View Post
    thats what I would also do

    @ontro
    here a sample you can adjust to your needs
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
      Dim nYear As Long
            Dim nMonth As Long
            Dim nDays As Long
            Dim LastDayOfMonth As Date
            Dim FirstDayOfMonth As Date
            Dim d As Date
            
            
            For nYear = 2024 To 2026 'set Year or Years to create Folders
                For nMonth = 1 To 12
                   
                    LastDayOfMonth = DateSerial(nYear, nMonth + 1, 0)
                    FirstDayOfMonth = DateSerial(nYear, nMonth, 1)
                    
                    'get a Day count in that month
                    d = DateSerial(nYear, nMonth, 1)
                    nDays = Day(DateAdd("m", 1, d) - 1)
                
                    List1.AddItem ("First Day Of Month : " & Format(FirstDayOfMonth, "dddd dd.MM.yyyy"))
                    List1.AddItem ("Days in Month : " & nDays)
                    List1.AddItem ("Last Day of Month  : " & Format(LastDayOfMonth, "dddd dd.MM.yyyy"))
                    List1.AddItem ("---------------------------------------------------------------------")
    
         FolderCreateNew "E:\TestFolder\Reports\" & nYear & "\" & Format(FirstDayOfMonth, "dd-MM-yyyy") & "  " & Format(LastDayOfMonth, "dd-MM-yyyy"), True
    'create folders like:
    'E:\TestFolder\Reports\2024\01-01-2024 31-01-2024
    'E:\TestFolder\Reports\2024\01-02-2024 29-02-2024
    'etc...
    
    
                Next nMonth
            Next nYear
    End Sub
    
    Public Function FolderCreateNew(Path As String, _
                                 Optional ShowError As Boolean = True) As Boolean
       Dim s As String
       Dim s1() As String
       Dim s2 As String
       Dim Titel As String
       Dim i As Long
       
          Titel = "FolderCreate"
       
          
          If Len(Trim(Path)) = 0 Then
             If ShowError Then
                yourError 1, "no path text", Titel
             End If
             Exit Function
          End If
          s = Replace(Trim(Path), "\\", "\")
          'remove last BackSlash
          If Right(s, 1) = "\" Then
             s = Left$(s, Len(s) - 1)
          End If
          
          'split into Folders
          s1() = Split(s, "\")
          
          'does the Path exist
          s2 = Join(s1(), "\")
          If Len(Dir(s2, vbDirectory)) > 0 Then
             If ShowError Then
                yourError 2, "Path " & Path & vbCrLf & _
                              "exist allready", Titel
             End If
             Exit Function
          End If
          
          s2 = s1(LBound(s1))
          'check for Drive
          If Len(Dir(s2)) = 0 Then
             If ShowError Then
                yourError 3, "Drive " & s2 & " not found !", Titel
             End If
             Exit Function
          End If
          
          'check the Path(s)
          On Error GoTo Fehler
          For i = LBound(s1) + 1 To UBound(s1)
             s2 = s2 & "\" & s1(i)
             If Len(Dir(s2, vbDirectory)) = 0 Then
                'Folder doesn't exsit, so create it
                MkDir s2
             End If
          Next
          FolderCreateNew = True
          Exit Function
    Fehler:
          If ShowError Then
             yourError err.Number, err.Description, Titel
          End If
    End Function
    
    Public Sub yourError(ErrNumber As Long, ErrDescription As String, _
                             Optional Titel As String = "")
    
       Dim Msg As String
       
          Msg = "Error " & ErrNumber & vbCrLf & vbCrLf & _
                ErrDescription
          MsgBox Msg, vbCritical, Titel
    End Sub
    No need for this convoluted CreateFolder-Function:
    https://learn.microsoft.com/en-us/wi...tedirectoryexw
    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

  12. #12
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,118

    Re: how to create a monthly folder automatically

    @Zvoni
    just show your example, Ontro would have two samples to choose from
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: how to create a monthly folder automatically

    okay
    now it's fine
    I just need to make folders for each day within each month's folder.
    thank you

  14. #14
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,026

    Re: how to create a monthly folder automatically

    Quote Originally Posted by ChrisE View Post
    @Zvoni
    just show your example, Ontro would have two samples to choose from
    Can't. No vb6 available, only Office-VBA 64-Bit.
    My "Solution" is more like "from the top of my head, what i can remember"
    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

  15. #15
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,496

    Re: how to create a monthly folder automatically

    Quote Originally Posted by ontro View Post
    okay
    now it's fine
    I just need to make folders for each day within each month's folder.
    thank you
    Maybe you should start your new threads with clear description of your needs.
    In this thread after each given answer you come up with additional requirements.

    It seems that you just want to create an hierarchical folder structure based on months and days.
    And the top level folders need to be YYYY-MM-01 and the subfolders need to be per day.

    I would create folders per year, in the year folder have folders for the 12 months and per month create a folder per day.
    Code:
    +2024
      + 01
         + 01
         + 02
         ..
         + 28
         + 29
         + 30
         + 31
      + 02
         ..
      + 03
      ..
      + 12

  16. #16
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,026

    Re: how to create a monthly folder automatically

    Quote Originally Posted by Arnoutdv View Post
    Maybe you should start your new threads with clear description of your needs.
    In this thread after each given answer you come up with additional requirements.

    It seems that you just want to create an hierarchical folder structure based on months and days.
    And the top level folders need to be YYYY-MM-01 and the subfolders need to be per day.
    Any bets, that the next question is going to be "How to find out, if it's a Leap Year"?
    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

  17. #17
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,118

    Re: how to create a monthly folder automatically

    Quote Originally Posted by ontro View Post
    okay
    now it's fine
    I just need to make folders for each day within each month's folder.
    thank you
    you allready have a count of the Days in each month, you need to create another loop for each Day-Folder 01..02 etc..
    Code:
    '...
                    'get a Day count in that month
                    d = DateSerial(nYear, nMonth, 1)
                    nDays = Day(DateAdd("m", 1, d) - 1)
                
                    List1.AddItem ("First Day Of Month : " & Format(FirstDayOfMonth, "dddd dd.MM.yyyy"))
                    List1.AddItem ("Days in Month : " & nDays)
    '....
    hope you are not going into Hours and then .....
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: how to create a monthly folder automatically

    I try to do this but it doesn't work


    Code:
    Dim nYear As Long
            Dim nMonth As Long
            Dim nDays As Long
            Dim LastDayOfMonth As Date
            Dim FirstDayOfMonth As Date
            Dim d As Date
            Dim lor As Long
            nDays = 31
            For nYear = 2024 To 2026
                For nMonth = 1 To 12
                  For lor = 1 To nDays
                    LastDayOfMonth = DateSerial(nYear, nMonth + 1, 0)
                    FirstDayOfMonth = DateSerial(nYear, nMonth, 1)
                    d = DateSerial(nYear, nMonth, 1)
                    nDays = Day(DateAdd("m", 1, d) - 1)
                
                
    
         FolderCreateNew App.Path & "\" & nYear & "\" & Format(FirstDayOfMonth, "dd-MM-yyyy") & "  " & Format(LastDayOfMonth, "dd-MM-yyyy"), True & "\" & lor
    
    
    
                   Next lor
                Next nMonth
            Next nYear

  19. #19
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,496

    Re: how to create a monthly folder automatically

    The code inside inner loop is not correct
    nDays is calculated inside the loop, but you are using it as the "To" in the for loop
    Also the call to FolderCreateNew seems not correct
    Code:
    For lor = 1 To nDays
      LastDayOfMonth = DateSerial(nYear, nMonth + 1, 0)
      FirstDayOfMonth = DateSerial(nYear, nMonth, 1)
      d = DateSerial(nYear, nMonth, 1)
      nDays = Day(DateAdd("m", 1, d) - 1)
      FolderCreateNew App.Path & "\" & nYear & "\" & Format(FirstDayOfMonth, "dd-MM-yyyy") & "  " & Format(LastDayOfMonth, "dd-MM-yyyy"), True & "\" & lor
    Next lor
    Do you want the following structure?:
    Code:
    +2024
      +01-01-2024  31-01-2024
         +1
         +2
         ..
         +31
    Can you please show an example of the output you want?
    A folder with the name "01-01-2024 31-01-2024" will be hard to access programmatically.

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: how to create a monthly folder automatically

    correct
    So what would an example with code be like?
    thank you

  21. #21
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,496

    Re: how to create a monthly folder automatically

    Code:
    Option Explicit
    
    Private Declare Function SHCreateDirectoryExW Lib "SHELL32.dll" (ByVal hwnd As Long, ByVal pszPath As Long, ByRef psa As Any) As Long
    
    Private Sub Form_Load()
      Dim lYear As Long, lMonth As Long, lDay As Long
      Dim lLastDay As Long
      Dim sYearFolder As String, sMonthFolder As String, sFolder As String
      
      For lYear = 2024 To 2026
        sYearFolder = App.Path & "\" & CStr(lYear)
        CreateFolder sYearFolder
        For lMonth = 1 To 12
          lLastDay = Day(DateSerial(lYear, lMonth + 1, 0))
          sMonthFolder = sYearFolder & "\" & Format(DateSerial(lYear, lMonth, 1), "DD\-MM\-YYYY") & "  " & Format(DateSerial(lYear, lMonth, lLastDay), "DD\-MM\-YYYY")
          CreateFolder sMonthFolder
          For lDay = 1 To lLastDay
            sFolder = sMonthFolder & "\" & CStr(lDay)
            CreateFolder sFolder
          Next lDay
        Next lMonth
      Next lYear
    End Sub
    
    Private Sub CreateFolder(sFolder As String)
      Debug.Print sFolder
      SHCreateDirectoryExW 0, StrPtr(sFolder), Nothing
    End Sub

  22. #22

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: how to create a monthly folder automatically

    resolved

    thank you so much

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: [RESOLVED] how to create a monthly folder automatically

    to get full path to save data in sequential file

    lYear lMonth lDay


    thank you

  24. #24
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,496

    Re: [RESOLVED] how to create a monthly folder automatically

    How to get these variables from a date variable?
    Check the help more often. It’s as simple as using Year(), Month() and Day()

  25. #25
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,026

    Re: [RESOLVED] how to create a monthly folder automatically

    Quote Originally Posted by ontro View Post
    to get full path to save data in sequential file

    lYear lMonth lDay


    thank you
    Is there a question somewhere i can't see?
    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

  26. #26

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: [RESOLVED] how to create a monthly folder automatically

    In the month variable I get month 5 and it should come out 05-01-2024 05-31-2024

    code

    Code:
     
    
    
    Dim route As String
        route = App.Path & "\" & Year(Now) & "\" & Month(Now) & "\" & Day(Now) & "\" & (nom + ".txt")

    thank you

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: [RESOLVED] how to create a monthly folder automatically

    ]n the month variable I get month 5 and it should come out 01-05-2024 31-05-2024


    Code:
    Dim route As String
        route = App.Path & "\" & Year(Now) & "\" & Month(Now) & "\" & Day(Now) & "\" & (nom + ".txt")

  28. #28
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,496

    Re: [RESOLVED] how to create a monthly folder automatically

    All the code for creating the folder name is post #21

  29. #29

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: [RESOLVED] how to create a monthly folder automatically

    this path is to save the data
    in the month(now) variable it reads month 5
    but it has to leave 05-01-2024 05-31-2024
    and it doesn't come out


    Code:
    Dim route As String
        route = App.Path & "\" & Year(Now) & "\" & Month(Now) & "\" & Day(Now) & "\" & (nom + ".txt")

  30. #30
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,496

    Re: [RESOLVED] how to create a monthly folder automatically

    The code for defining the folder is in post 21
    Read it, take the folder building string code and use it.

    I give up..

  31. #31

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: [RESOLVED] how to create a monthly folder automatically

    I give up

    thank you so much

  32. #32

  33. #33

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    264

    Re: [RESOLVED] how to create a monthly folder automatically

    I need the current date of:

    Code:
    sMonthFolder = sYearFolder & "\" & Format(DateSerial(lYear, lMonth, 1), "DD\-MM\-YYYY") & "  " & Format(DateSerial(lYear, lMonth, lLastDay), "DD\-MM\-YYYY"
    to search



    Code:
    Dim route As String
        route = App.Path & "\" & Year(Now) & "\" & sMonthFolder & "\" & Day(Now) & "\" & (nom + ".txt

    thank you

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