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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use date

Hello

I need to build two dates: in this year 2013 i like to build 20130101 - 20131231. The next year i need 20140101 - 20141231.

It mean it is only the year i need to caluculate the date and month is static.

//Gunnar

1 Solution

Accepted Solutions
Not applicable
Author

I believe you are getting zero because you didnt open and close the parenthesis after the Today() functions.  It should look like this...

sum( {$<AcNo= {'>=3000<=3999'},VoDt= {'>$(=date(yearstart(today()),'YYYYMMDD'))<$(=date(yearend(today()),'YYYYMMDD'))'}>} AcAm)

Everything else looks good as long as the dates are the same format.  Is VoDt formatted like YYYYMMDD?

Haushik, your expression will start the year in April.  Yearstart would be 20130401 where it should be 20130101, correct?

View solution in original post

7 Replies
Not applicable
Author

Hi,

These expressions calculate these dates based on the current year.  What are you using them for?  Just display or in the script?  Let me know if you need more help

Current Year Start and End

Date(YearStart(Today()),'YYYYMMDD')

Date(YearEnd(Today()),'YYYYMMDD')

Next Year Start and End

Date(YearStart(AddYears(Today(),1)),'YYYYMMDD')

Date(YearEnd(AddYears(Today(),1)),'YYYYMMDD')

-art

Not applicable
Author

Thank's for fast answer!

I will use it in expression like this

sum( {$<AcNo= {'>=3000<=3999'},VoDt= {'>Year0101<Year1231'}>} AcAm)

(Year0101 and Year1231 should be 20130101 and 20131231

//Gunnar

Not applicable
Author

Ok.  Good luck.  Can you give me a 'correct answer' if it works, please.

Not applicable
Author

How can i test result of a single expression?

I i just want to see the result of: Date(YearStart(Today()),'YYYYMMDD')

//Gunnar

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try below expression.

    

     sum( {$<AcNo= {'>=3000<=3999'},VoDt= {'>$(=date(yearstart(VoDt,0,4),'YYYYMMDD'))<$(=date(yearend(VoDt,0,4),'YYYYMMDD'))'}>} AcAm)

Regards,

Kaushik Solanki    

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hmmm i get 0 with this expression: (Expression is OK, but the result of expression is 0)

sum( {$<AcNo= {'>=3000<=3999'},VoDt= {'>$(=date(yearstart(today),'YYYYMMDD'))<$(=date(yearend(today),'YYYYMMDD'))'}>} AcAm)

I asume i say with this espression:

Sum filed AcAM (Ammount) with AcNo (AccountNr) between 3000 and 3999 and VoDt (VoucherDate) between the start of current year and the end of current year.

/Gunnar

Not applicable
Author

I believe you are getting zero because you didnt open and close the parenthesis after the Today() functions.  It should look like this...

sum( {$<AcNo= {'>=3000<=3999'},VoDt= {'>$(=date(yearstart(today()),'YYYYMMDD'))<$(=date(yearend(today()),'YYYYMMDD'))'}>} AcAm)

Everything else looks good as long as the dates are the same format.  Is VoDt formatted like YYYYMMDD?

Haushik, your expression will start the year in April.  Yearstart would be 20130401 where it should be 20130101, correct?