Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Extract month from MM/DD/YYYY format

Hi everyone,

I am trying to extract the month from my date format, however I am not doing it correctly. Should I create a timestamp for my dates and extract the month only after?

Tags (3)
1 Solution

Accepted Solutions
rubenmarin
Not applicable

Re: Extract month from MM/DD/YYYY format

I think is for the separator, in the first case you're using '-' instead of '/'

6 Replies
rubenmarin
Not applicable

Re: Extract month from MM/DD/YYYY format

Hi Pedro, if that's not your regional date format you call tell QV wich date format is, to extract month you can use:

=Month(Date#(Day, 'MM/DD/YYYY'))

Notice that internally date is a number, looking on your Day list box you can see that values are left aligned, this tells that it is a string, not a number (numbers are right aligned), so for Qlikview Day field is text, not number (=not date).

anbu1984
Not applicable

Re: Extract month from MM/DD/YYYY format

First convert your input to Date using Date#()

Load *,Month(Day) As Mth;

Load Date#(Day,'M/D/YYYY') As Day,Count From Source;

Not applicable

Re: Extract month from MM/DD/YYYY format

But I am already doing it!

From my script:

" Date#(('$(vFileDate)'),'MM-DD-YYYY') as Day,"

But only I do it for the secound time it works:

" Date#(Day, 'MM/DD/YYYY') as Day234"

In Qlikview Day is a string but Day234 is already a date. Why it only works when I call for the second time the same function?

rubenmarin
Not applicable

Re: Extract month from MM/DD/YYYY format

I think is for the separator, in the first case you're using '-' instead of '/'

Not applicable

Re: Extract month from MM/DD/YYYY format

The machine is always right. I dont know why I didnt notice that.


Thanks!

jpapador
Not applicable

Re: Extract month from MM/DD/YYYY format

Replace Month(Day) in your script with the following:

Month(Num(Date#(Day, 'M/DD/YYYY')))