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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Data Manipulation inside Load Script

Hi to all,

I have several issues to resolve. I need to:

1 convert string in date format in the load script

2 create two calculate field that are the difference in network days

For the first isse a tried

Table1:

SQL SELECT DateField,

Position

Number

FROM Table_from_the_system;

Load Position,

Number,

date(date#(DateField,'DD/MM/YYYY hh:mm:ss'),'DD/MM/YYYY')as NewDate RESIDENT Table_from_the_system;

But doesn't work !! The NewDate field is Empty

( Datefield is a string )

1 Solution

Accepted Solutions
MayilVahanan

Hi

Did you try

date(DateField,'DD/MM/YYYY') as NewField

or

date(timestamp(DateField,'DD/MM/YYYY hh:mm:ss'),'DD/MM/YYYY')

Am not sure why you use date#(), are you sure , its text format??

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

6 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

networkdays(Date1,Date2) returns the net number of workdays between Date1 and Dat2 (as long as they are dates and not strings).

Check that the date format matches the format of the DateField string.

Also you use resident Table_from_the_system. But looking at your example don't you need resident Table1 instead?


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks Gysbert,

the networkdays works.

But the main problem is the string "date(date#(DateField,'DD/MM/YYYY hh:mm:ss'),'DD/MM/YYYY')as NewDate"

that doesn't work and I don't know why.

I wrong to copy "Resident Table_from_the_system is wrong" the correct string is "Resident Table1"

Anonymous
Not applicable
Author

I'd expect that the DateField in the database has date format already, so the syntax is:

date(DateField) as NewDate

or

date(floor(DateField)) as NewDate                              // to remove time part

or

date(floor(DateField), 'DD/MM/YYYY') as NewDate     // to enforce format

If it is not a date field, you need to use date#() as well - make sure you got the format right in this case.

Regards,

Michael

MayilVahanan

Hi

Did you try

date(DateField,'DD/MM/YYYY') as NewField

or

date(timestamp(DateField,'DD/MM/YYYY hh:mm:ss'),'DD/MM/YYYY')

Am not sure why you use date#(), are you sure , its text format??

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

It Works !!

with the second solution, but isn't clear for me why works.

What do the timestamp function ?

Thanks

MayilVahanan

HI

From help:

The timestamp function formats the expression as a date and time according to the string given as format-code. If the format code is omitted, the date and time formats set in the operating system are used.

And i think, from sql format is like DD/MM/YYYY hh:mm:ss format..so timestamp calculate the value exactly n give the result..

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.