QUERY OR FUNCTION TO CONVERT DATE TO AN EXPRESSION (1 Viewer)

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:07
Joined
May 7, 2009
Messages
19,175
Code:
SELECT "TERM " & ((Month(Date())-1)\4)+1 AS TERM
Code:
Public Function getTerm(Optional ByVal p As Variant = "") As String
    If IsDate(p) Then
        p = Month(p)
    Else
        p = Val("0" & p)
    End If
    If p < 1 Then p = Month(Date)
    getTerm = "TERM " & ((p - 1) \ 4) + 1
End Function
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:07
Joined
May 21, 2018
Messages
8,463
This is not what I meant but thanks for your query. What I mean is the term has 4 months that is:
JANUARY, FEBRUARY, MARCH, APRIL- TERM ONE
MAY, JUNE JULY, AUGUST- TERM TWO
SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER- TERM THREE
And what I provided does not work because why????
="Term " & (Month(Date)-1)\4+1

You do under stand I was showing that it works for all months.
 

mercystone

Member
Local time
Today, 18:07
Joined
Sep 20, 2021
Messages
108
Code:
SELECT "TERM " & ((Month(Date())-1)\4)+1 AS TERM
Code:
Public Function getTerm(Optional ByVal p As Variant = "") As String
    If IsDate(p) Then
        p = Month(p)
    Else
        p = Val("0" & p)
    End If
    If p < 1 Then p = Month(Date)
    getTerm = "TERM " & ((p - 1) \ 4) + 1
End Function
Genius. Thanks. Be blessed.
 

mercystone

Member
Local time
Today, 18:07
Joined
Sep 20, 2021
Messages
108
And what I provided does not work because why????
="Term " & (Month(Date)-1)\4+1

You do under stand I was showing that it works for all months.
It works. Thanks. Be blessed.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:07
Joined
May 21, 2018
Messages
8,463
FYI. If you were doing standard quarters of a year that is already built in to the format function
"Term " & format(date,"q")
Term 4
Unfortunately there is no constant for a 3rd of a year only a quarter of a year.
 

Users who are viewing this thread

Top Bottom