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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
ali_hijazi
Partner - Master II
Partner - Master II

create functions inside the script editor

Hello

is there a possibility to create a function inside our script and use this function in our load statements?

I mean I want to create a function that takes a numeric parameter and returns a valid DateTime

actually now I'm writing the following

case lendth(trim(char(csdate))) ,.....

where csDate is supposed to be a date value in the client's database but is actually saved as integer as follows:

3231 this means it is 23 of january 2003!!

so what I want is wite a function to convert this integer value into a valid datetime value

this technic of saving dates as integer is existing in several tables

I can walk on water when it freezes
4 Replies
Not applicable

You can write a macro function and do it that way (control + m).  As far as your actual example goes I don't actually know how to write it but if you just write it in a macro you can use it as a function in your script very easily.

Anonymous
Not applicable

You wouldn't need a custom function for this, but it would be helpful with a better explanation of the format used.

In your example it looks like they use YDDM, so what is the number for a date like 1999-12-31? 993112?

ali_hijazi
Partner - Master II
Partner - Master II
Author

yes this is the format

I can walk on water when it freezes
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Try below function.

   

Sub abc(Number)

call = date(date#(Number,'YDDM'),'YY-DD-MM')

End sub

load

'$(call)' as date

AutoGenerate 1;

Regards,

Kaushik solanki

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