Month Name from Date range (1 Viewer)

syedadnan

Access Lover
Local time
Today, 07:53
Joined
Mar 27, 2013
Messages
315
I have two date fields in table one is "From" and another is "To" i want in query or report that suppose if date from is 31/08/2016 and to is 30/11/2016 then month name should be displayed like this in new query field or report text box

Aug-16,Sept-16,Oct-16,Nov-16
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:53
Joined
Jul 2, 2005
Messages
13,826
You would need to create you own procedure that returns the string value; a User Defined Function (UDF). Have you done one before as it requires using VBA code.
 
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:53
Joined
Aug 30, 2003
Messages
36,126
?format(date(),"mmm-yy")
Nov-16
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:53
Joined
Aug 30, 2003
Messages
36,126
Ack! Sorry Allan, didn't see your post.
 

syedadnan

Access Lover
Local time
Today, 07:53
Joined
Mar 27, 2013
Messages
315
You would need to create you own procedure that returns the string value; a User Defined Function (UDF). Have you done one before as it requires using VBA code.

No i cant write vba, if you plz help here :banghead:
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:53
Joined
Jul 2, 2005
Messages
13,826
I'll see if I can't put something together for you.
 

MarkK

bit cruncher
Local time
Yesterday, 20:53
Joined
Mar 17, 2004
Messages
8,181
Here's one way, not well tested...
Code:
Function GetInterveningMonths(ByVal d1 As Date, d2 As Date) As String
    Dim tmp As String
    
    Do While d1 < DateAdd("m", 1, d2)
        tmp = tmp & ", " & Format(d1, "mmm-yy")
        d1 = DateAdd("m", 1, d1)
    Loop
    If Len(tmp) Then GetInterveningMonths = Mid(tmp, 3)
End Function
 

syedadnan

Access Lover
Local time
Today, 07:53
Joined
Mar 27, 2013
Messages
315
Here's one way, not well tested...
Code:
Function GetInterveningMonths(ByVal d1 As Date, d2 As Date) As String
    Dim tmp As String
    
    Do While d1 < DateAdd("m", 1, d2)
        tmp = tmp & ", " & Format(d1, "mmm-yy")
        d1 = DateAdd("m", 1, d1)
    Loop
    If Len(tmp) Then GetInterveningMonths = Mid(tmp, 3)
End Function



Tested done and absolutely accurate to my requirement.. Thanks a lot Markk...
 

Users who are viewing this thread

Top Bottom