Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
ValeriaBonini
Partner - Creator
Partner - Creator

Modify a date

I have a date field with many dates (format DD/MM/YYYY), i would like to create a new column with these conditions:

 

if date is between 13/08/YYYY and 17/08/YYYY -> date become 15/09/YYYY

if date is between 13/12/YYYY and 17/12/YYYY -> date become 15/01/YYYY

 

 

how can I do this?

Labels (6)
2 Solutions

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

You need to convert this into date. Try below expression

Date(If(num(Month([Your Date Field]))=8 and Day([Your Date Field]) >=13 and Day([Your Date Field]) <=17,

Makedate(Year([Your Date Field]),09,15),

If(num(Month([Your Date Field]))=12 and Day([Your Date Field]) >=13 and Day([Your Date Field]) <=17,

Makedate(Year([Your Date Field]+1),01,15),

[Your Date Field]))) as NewDate

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

View solution in original post

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Ohh Yes change below code.

Makedate(Year([Your Date Field]+1),01,15) 

to

Makedate(Year([Your Date Field])+1,01,15),

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

View solution in original post

11 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Try this,

 

If(num(Month([Your Date Field]))=8 and Day([Your Date Field]) >=13 and Day([Your Date Field]) <=17,

Makedate(Year([Your Date Field]),09,15),

If(num(Month([Your Date Field]))=12 and Day([Your Date Field]) >=13 and Day([Your Date Field]) <=17,

Makedate(Year([Your Date Field]+1),01,15),

[Your Date Field])) as NewDate

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
ValeriaBonini
Partner - Creator
Partner - Creator
Author

Hi, it doesn't work (dont look at the strange years)

OLD DATE                        NEW DATE

ValeriaBonini_0-1669629943895.png

 

vinieme12
Champion III
Champion III

this could be simplified as below

 

if(day(DATEFIELD)>=13  and day(DATEFIELD)<=17,date(monthstart(DATEFIELD),1)+14)) as newDatefield

 

replace DATEFIELD with your actual datefield name

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

You need to convert this into date. Try below expression

Date(If(num(Month([Your Date Field]))=8 and Day([Your Date Field]) >=13 and Day([Your Date Field]) <=17,

Makedate(Year([Your Date Field]),09,15),

If(num(Month([Your Date Field]))=12 and Day([Your Date Field]) >=13 and Day([Your Date Field]) <=17,

Makedate(Year([Your Date Field]+1),01,15),

[Your Date Field]))) as NewDate

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
ValeriaBonini
Partner - Creator
Partner - Creator
Author

Now it works, but if we are in the december case it doesn't add a Year

ValeriaBonini_0-1669631060652.png

 

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Ohh Yes change below code.

Makedate(Year([Your Date Field]+1),01,15) 

to

Makedate(Year([Your Date Field])+1,01,15),

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
ValeriaBonini
Partner - Creator
Partner - Creator
Author

solved, but it was 

 

Date(If(num(Month([Your Date Field]))=8 and Day([Your Date Field]) >=13 and Day([Your Date Field]) <=17,

Makedate(Year([Your Date Field]),09,15),

If(num(Month([Your Date Field]))=12 and Day([Your Date Field]) >=13 and Day([Your Date Field]) <=17,

Makedate(Year(([Your Date Field])+1),01,15),

[Your Date Field]))) as NewDate

ValeriaBonini
Partner - Creator
Partner - Creator
Author

thank you so so much!!

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

My Pleasure 🙂

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