Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
month(date)
Month. Returns a text string representing the month when the fraction of expr is interpreted as a date, but can be formatted as a number. Example: month( '1971-10-30' ) returns Oct.
Well, that's again a nice example of a bad maintained Help text and showing the disadvantages of allowing the use of copy and paste to the technical writers It's hard to understand, even for me.
expr is not defined in that Helps topics context, it was used in the explanation of hour(), minute() and second().
Replace expr with the argument passed to the function month() [In the Help, the argument alias used is date, which might lead to further confusion]
Also, month() is not looking at the fraction of the argument, but on the integer part...
If someone would offer me a job as QT QA, I would accept, must be a lazy job....
Ok, let me try to explain month() function to you
month() takes one argument, an expression that QV must be able to interprete as number.
A date type has a numerical representation within QV, so we can pass a QV date type field or a an expression / function that returns a date (and that's I would call the 'normal' use, passing a date).
Example
Month( today() )
today() returns today's date, this is the argument to month() function.
If you pass any other numerical, QV will interprete it as date, the integer part is telling the actual date, the fractional part the time of day.
Month() now will return a dual value, that's a special value that holds two representations, a textual and a numerical. Please refer to the Help or manual, looking for dual() function.
In the numerical representation, QV will put in the month number, ranging from 1-12. In the textual representation, QV will put in the Month name abbreviation that you defined in your OS or using the standard format setting in the script:
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';
So, for our example Month( today() ), QV will use return a dual with
6 as numerical representation, and 'Jun' as textual representation.
You can force QV at anytime to return the textual part of a dual using text(dualvalue), e.g. text(month( today() )) will return 'Jun', and using num(dualvalue), e.g. num(month(today())) will return 6.
If you don't specify the representation you want returned, QV will use it's internal logic. I believe, if you use
month( date ) as dimension, it will use the textual representation by default (but maybe you have changed that default in document settings or somewhere else?).
So I can't answer your question why you don't get the text in your dimension values (but you can try to use text(Month) as dimension, as mentioned.
If possible, post a small sample app, so someone can have a look what is going on in your app.
Hope this helps,
Stefan
coalesce is a (Transact-)SQL statement, not a QV function.
Are you using month in a LOAD or SELECT context?
You can't use Month() as described above in the SELECT part, here you will use the SQL function...
But you can use the QV Month() function in a preceding load:
LOAD
Date,
Month(Date) as Month;
SELECT Coalesce(OM.ClosedDate,'1/1/1989') as Date FROM ...
Hello.
Are you applying the Month function on your SQL statement?
If so, you need to change the statement to apply the QV Month function on your date, not the DB2 Month function.
Something like this:
Load
ClosedDate,
Month(ClosedDate) as ClosedDate_Month
;
SQL SELECT
COALESCE(ClosedDate,'1/1/1989')) as ClosedDate
FROM YourTable
;
>Is there a way to put a label on this so that it simply shows "Month"?
There should be an entry box on dimension tab (under the label check box) that by default says <use field name>.
Put in: Month
But I think you should solve your underlying problem instead of using text(month(date)) here and there.
Are you using more than one Month field (field named Month in different tables) in your QV data model?
Again, could you post a small sample app? Maybe with scrambled / mock up data if needed?
I assumed up to now that you stepped already through the free e-learning and offline tutorial files, have you?
I wouldn't recommend to start loading from a large database, start with something really simple (as the tutorial does).
If you need to do so, there are some methods limiting the amount of rows returned (debug mode in script editor, first prefix to load statement, where clause...)
If you are looking for link for Newbies, there is a whole section here in the community:
>and entered the expression "=text(Month(Month)), my list box displays (just the first few entries, don't know how to paste images):1 -2 -3 Jan4 -
Your Month field values are no dates, but duals and have a numerical repesentation (assuming you have created your Month field from a date using the QV month() function in a LOAD context).
3 is representing Jan 2nd 1900 (so you can guess what 1 is representing). That's why you get Jan returned. But I can't explain why you don't get Month names for the other list box lines.