Months

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")))
 
J

John Spencer

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)
 
K

Ken Snell \(MVP\)

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)))
 
G

Guest

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")))
 
V

Van T. Dinh

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))
 
J

John Spencer

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")))
 
K

Ken Snell \(MVP\)

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!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top