Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2010
    Posts
    36

    Unanswered: function to rollout date

    dear access profesionals

    i need function to display the date for each month seperately.

    for example i have date 12/november/2010. I would like to write a function that shows like following

    12/november/2010
    12/December/2010
    12/january/2011.

    any help is appreciated.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Use the DateAdd() function to add one month to the initial date. You can place that line into a loop, then use the Format() function to convert the resulting date(s) to whatever format you see fit.
    Have a nice day!

  3. #3
    Join Date
    Dec 2010
    Posts
    36
    if you have an example it is appreciated.
    thanks

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Here:
    Code:
    Option Compare Database
    Option Explicit
    
    Function NextMonth(ByVal OriginalDate As Date) As Date
    
        NextMonth = DateAdd("m", 1, OriginalDate)
        
    End Function
    
    Sub ShowNextMonths(ByVal OriginalDate, ByVal Count As Integer, ByVal DateFormat As String)
    
        Dim i As Integer
        Dim CurrentDate As Date
        
        CurrentDate = OriginalDate
        For i = 1 To Count
            CurrentDate = NextMonth(CurrentDate)
            Debug.Print Format(CurrentDate, DateFormat)
        Next i
        
    End Sub
    Now:
    Code:
    ShowNextMonths now,12,"dd/mmmm/yyyy"
    Here yields:
    Code:
    17/février/2011
    17/mars/2011
    17/avril/2011
    17/mai/2011
    17/juin/2011
    17/juillet/2011
    17/août/2011
    17/septembre/2011
    17/octobre/2011
    17/novembre/2011
    17/décembre/2011
    17/janvier/2012
    Have a nice day!

Posting Permissions

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