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

Finding out the length of a string

Hi All,

I have a field in excel which consists of values in DD-MM-YYYY hh:mm:ss TT Format.

I wish to find out the length of the number of characters present in the field value in the script.

e.g. if value is 12/12/2014 01:10:00 AM , then length should be 22.

Thanks,

Asma

25 Replies
MarcoWedel

Len('12/12/2014 01:10:00 AM')

MarcoWedel

QlikCommunity_Thread_167244_Pic1.JPG

What do you need this length for?

Maybe there are other possibilities than calculating the length of this string ...

regards

Marco

Not applicable
Author

How do I calculate this length in the script?

If I use the expression len(fieldname), then it returns the number of characters present in the word fieldname. I want to calculate the length of field values in the backend

PrashantSangle

Hi,

USe

Len(Timestamp#(FieldName,'DD/MM/YYYY hh:mm:ss tt')) as Len_dateField

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
petter
Partner - Champion III
Partner - Champion III

Marco is right and I can't possibly imagine which situation that will return the length of the word fieldname when you have the expression len(fieldname) - that is if fieldname has a value that is the same length as the word fieldname that could explain it.... len('fieldname') on the other hand should give the result you have.

Is it a Load Script you are referring to? A QlikView Load Script? Could you show us the part of the load script that fails? Where is the expression located in a Load statement or as an expression for a variable outside a load statement?

MarcoWedel

len(fieldname)


does not return the length of the word 'fieldname' but the length of the values of this field.

In the script

LOAD Len(yourfield) as YourFieldLength

FROM yoursource;

should work.

Do you have a example data?


regards


Marco

Not applicable
Author

This is not working either.

If value is 3/1/2015 02:14:00 AM , it is returning length as 10 which is incorrect

Not applicable
Author

If fieldvalue is '1/3/2015 02:04:50 AM', then it is returning length as 10 which is incorrect

MarcoWedel

please provide a sample of the excel source file and the part of your script that fails.

Maybe it's loading a numerical value from excel that is formatted as Timestamp in the script but len() counts the digits of the numerical representation or something like that.

regards

Marco