Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Month(today()) returning null value

Hi All,

It's NYE, so this is probably a result of the end of the working year, but this is confusing the life out of me.

I have two variables I'm declaring at the beginning of my script:

let vCurrentYear  = year(today());

let vCurrentMonth = month(today());

The first correctly returns 2013.

The second appears to return a null value (to check I put both into separate text objects on my sheet. The vCurrentMonth displays as '-', the vCurrentYear as '2013').

Any ideas?

Thanks!


Rory.

1 Solution

Accepted Solutions
Not applicable
Author

Rory Webber wrote:

Isn't Month() supposed to return an int?

Month() returns a dual data type, i.e. text and a number. You need to use Num(Month(today())) to return an int.

View solution in original post

11 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Works for me though. Are you sure you made no spelling mistakes in your text box?

To be sure, open Settings->Variables in your QV Desktop and check the value of vCurrentMonth.

Peter

sivarajs
Specialist II
Specialist II

try by using

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec'; in script

Not applicable
Author

OK - more confusion now!

In the Variable Overview it shows that vCurrentMonth has a value of 'Dec'. Isn't Month() supposed to return an int? On the text box I used the variable lookup dropdown to insert the variable name, so shouldn't be a spelling issue '=$(vCurrentMonth)' is the value in the text box expression.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Aha! I see...

Put the following in your text box expression window:

='$(vCurrentMonth)'

That should work.

Best wishes,

Peter

Not applicable
Author

Rory Webber wrote:

Isn't Month() supposed to return an int?

Month() returns a dual data type, i.e. text and a number. You need to use Num(Month(today())) to return an int.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Month() returns a dual, which displays as 'Dec' but has an underlying value of 12. Don't use $() explansion as it will attempt to calculate the expression 'Dec' which will return null. Just use =vCurrentMonth.

The $() expansion works for the year, because that is straight numeric, but  it is unnecessary, so also use =vCurrentYear

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

=num(Month(Today()); then you have your int.

suniljain
Master
Master

Please try

=Text(Month(today()))

Not applicable
Author

Hi ,

can u pls try this

=month(Now())