I am facing a problem for the below code:
Timestamp(Timestamp#(UNPACKAGED_DATE_TIME,'DD-MMM-YY hh:mm:ss.fff TT'),'MM/DD/YYYY h:mm:ss[.fff] TT') as UNPACKAGED_DATE_TIME;
select FILE_ID, UNPACKAGED_DATE_TIME
from edi_e2e_user.abc_e2e_tracking_record where FILE_ID = 'ci1534054081616.19521239@sbycsaxy05_te';
when I execute the above code, I got nothing for UNPACKAGED_DATE_TIME, but when I hard coding date as
Timestamp(Timestamp#('11-AUG-18 08:38:01.000000000 PM','DD-MMM-YY hh:mm:ss.fff TT'),'MM/DD/YYYY h:mm:ss[.fff] TT') as UNPACKAGED_DATE_TIME
the data is coming well. Please suggest what should I do now.
I just tried a few localization-strings and it seems that some don't work especially those ones which contain not only letters like () or - and I would consider it as a bug (either by parsing the strings or within the documentation). But using the following worked for me:
Beside this your date() formatting will just show the values as date but they remain a timestamp. If you want to get a date you need something like this:
date(floor(YourTimestamp)) as Date
time(frac(YourTimestamp)) as Time
to get the time. Quite often it's useful to split timestamps in this way to reduce the number of distinct values of a field.
I seems that the timestamp-format from UNPACKAGED_DATE_TIME is a bit different to your expectation and therefore the timestamp#() conversion fails. Just comment the preceeding part to load the data without any transformation and then put UNPACKAGED_DATE_TIME within a tablebox to look for the real values and if there is no differences visible maybe to export/copy them into excel and/or an editor like notepad ++ to identify each single char.
That probably means your timestamp format is not matching. What is your data source? How does it look if you load in qlik directly (without any formatting)? If it is already in number format, you could directly try loading like:
Timestamp(UNPACKAGED_DATE_TIME, 'MM/DD/YYYY h:mm:ss.fff TT') as UNPACKAGED_DATE_TIME;
The value for that field is:
'11-AUG-18 08:38:01.000000000 PM'
but the point is when I use it in a KPI, it is showing correct value, but when I use it in a preceding load it shows nothing.
Something between your value and your specified formatting does not match. One point could be that your specified qlik-variables for MonthNames (by default at the beginning of your script in tab Main) and/or these regional-setting of your machine are different to your values - because the available month-name abbreviation - for ...AUG... - must fit with your values to be matchable.
Further you need to know exactly which chars are in your values - each additionally space or maybe a tab instead of a space or something similar will break the conversion. Therefore try my suggestion from above.
My data source is Oracle and Datatype is Timestamp.
My value at oracle field is: '11-AUG-18 08:38:01.000000000 PM'
When I use your expression the value is changed to: 12-08-2018 06:08:01 AM.
It is noted that I am using the below expression:
Timestamp(UNPACKAGED_DATE_TIME, 'MM/DD/YYYY h:mm:ss.fff TT') as UNPACKAGED_DATE_TIME
Please advise what should I do now?
I think this means that your values are already numerical timestamps and no strings because the timestamp() formatting doesn't returned NULL. Your noticed differences between origin and formatted value is caused through different timezones. For this you could try to adjust it with converttolocaltime() or with a manually adjusting with something like:
Timestamp(UNPACKAGED_DATE_TIME - (1/24*9.5), 'MM/DD/YYYY h:mm:ss.fff TT')
I have used the below code , but is showing 12th August 2018,
convertToLocalTime(UNPACKAGED_DATE_TIME, 'Eastern Time (US & Canada)') as DATE_TRAN
but the below code is working fine:
Date(Timestamp(UNPACKAGED_DATE_TIME - (1/24*9.5)), 'MM/DD/YYYY h:mm:ss.fff TT') as UNPACKAGED_DATE_TIME
So please advise me if my client's time zone format is: Eastern Time (US & Canada), then what will be the better option?
It seems that your timezone-string isn't correct and missed an A by US and also the spelling of the first char of Canada seems to be a K (at least within the german help it looked in this way):
convertToLocalTime(UNPACKAGED_DATE_TIME, 'Eastern Time (USA & Kanada)')