Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Get only a portion of Dates

Hello,

I'm trying to get only a portion of a date for different menu selection options.  For example. I would like to only get the Month. I have a field called sys_date stored in a format of M/D/YYYY h:mm:ss AM/PM.  On potential problem is that it changes formats when month or days reach double digits:  MM/DD/YYYY hh:mm:ss AM/PM.

I would like to extract only the month. and only the year for selection.

I tried using MonthName(Sys_Date,3), which gave me a 3 letter month name, but was sorted funny in the menu because the function returns an underlying number based on the month and year, per the help file.

I tried looking for something like a charindex and found FindOneOf, but couldn't get this to work with a date.  I tried Left and Mid functions as well, and just can't come up with the right answer.

I also tried editing the SQL directly but that through some errors

I would also like to get just the year.

Is it possible to pull just they Month out in one field, and the Year out in another field.

This can't be that hard, but I just can't get it to click today.

Thanks in advance for your assistance!

Greg

1 Solution

Accepted Solutions
sunny_talwar

Have you tried using Month() function to extract Month and Year() function to extract Year?

What output are you looking for?

Best,

Sunny

View solution in original post

3 Replies
sunny_talwar

Have you tried using Month() function to extract Month and Year() function to extract Year?

What output are you looking for?

Best,

Sunny

Not applicable
Author

I thought I had.  I either had too many parameters or a typo for those functions, because they didn't work originally.

I retried them and double checked my syntax and it worked! Yay!

Sorry for the bad question.  Thanks for the quick help!

Greg

sunny_talwar

Not a problem. Once in a while, we all go through something similar. but I am glad you found out your typo quick enough

Best,

Sunny