Months

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to create a value called Months then call the results Jan, Feb,
Mar... based on the Closed Date. But I don't want to include the year so that
it will work year after year... This code may help you understand what I'm
trying to accomplish.


Months: IIf([IssueCloseDate] Is Null,Null,IIf([IssueCloseDate] Between
1/1/2006 And 1/31/XXXX,"Jan",IIf([IssueCloseDate] Between 2/1/XXXX And
2/28/2006,"Feb")))
 
How about just using the format function on the close date?

Format(IssueCloseDate,"mmm")

This will return a zero-length string if IssueCloseDate is null. If you
really need the null then you will have to use an IIF expression to test for
that

IIF(IsDate(IssueCloseDate),Format(IssueCloseDate,"mmm"),Null)
 
Why not use the built-in function MonthName?

For example,

?MonthName(Month(Date()))
November

So:

Months: MonthName(Month(IssueCloseDate))

If you indeed need to handle Null in the field:

Months: IIf(IssueCloseDate Is Null, Null, MonthName(Month(IssueCloseDate)))
 
Sometimes Life Is Good!!!!
Thanks - both of you..

Ken Snell (MVP) said:
Why not use the built-in function MonthName?

For example,

?MonthName(Month(Date()))
November

So:

Months: MonthName(Month(IssueCloseDate))

If you indeed need to handle Null in the field:

Months: IIf(IssueCloseDate Is Null, Null, MonthName(Month(IssueCloseDate)))
--

Ken Snell
<MS ACCESS MVP>

Dan @BCBS said:
I'm trying to create a value called Months then call the results Jan, Feb,
Mar... based on the Closed Date. But I don't want to include the year so
that
it will work year after year... This code may help you understand what
I'm
trying to accomplish.


Months: IIf([IssueCloseDate] Is Null,Null,IIf([IssueCloseDate] Between
1/1/2006 And 1/31/XXXX,"Jan",IIf([IssueCloseDate] Between 2/1/XXXX And
2/28/2006,"Feb")))
 
If you want the abbreviated month name rather than the full month name, you
can use:

Months: IIf(IssueCloseDate Is Null, Null, MonthName(Month(IssueCloseDate),
True))
 
MonthName(Month(Date())) works in versions where MonthName is supported
(Access 2K and later).

I just tend to prefer one function call over two or more function calls. I
think (no proof) that one call is more efficient (generally). On the other
hand, there is probably not enough difference in the speed of the solutions
to be detectable by the average human or the average superhuman.

Ken Snell (MVP) said:
Why not use the built-in function MonthName?

For example,

?MonthName(Month(Date()))
November

So:

Months: MonthName(Month(IssueCloseDate))

If you indeed need to handle Null in the field:

Months: IIf(IssueCloseDate Is Null, Null,
MonthName(Month(IssueCloseDate)))
--

Ken Snell
<MS ACCESS MVP>

Dan @BCBS said:
I'm trying to create a value called Months then call the results Jan,
Feb,
Mar... based on the Closed Date. But I don't want to include the year so
that
it will work year after year... This code may help you understand what
I'm
trying to accomplish.


Months: IIf([IssueCloseDate] Is Null,Null,IIf([IssueCloseDate] Between
1/1/2006 And 1/31/XXXX,"Jan",IIf([IssueCloseDate] Between 2/1/XXXX And
2/28/2006,"Feb")))
 
John Spencer said:
I just tend to prefer one function call over two or more function calls.

Generally, I agree.... < g > but sometimes the memory finds the doubled-up
idea faster than the single-up one! (Especially as I age!)
 
Back
Top