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: 
Anonymous
Not applicable

Date format changes before storing as global variable

I have a tExtractRegexField which looks for a Date string like
 "(\\d{2}-\\D{3}-\\d{2})"

so it will find dates like 01-Feb-16 a.k.a "dd-MMM-yyyy"
That works but I need to store the date in globalmap so I add a tJavaRow as the next component
globalMap.put("MyDate", row3.ReportDate);

In debugging mode I can see the ReportDate as "DayOfWeek MonthAsString DayAsNumber 00:00:00 TimeZone Year"
Is there a way to specify the date format as "dd-MMM-yyyy" as the way to store the date in the globalmap
Labels (3)
3 Replies
cterenzi
Specialist
Specialist

You can convert it to a string before you store it, but then you lose the flexibility of the date format.  You could also convert it to a string with a specific format before printing it.
TRF
Champion II
Champion II

Try this as the field seems to be of String datatype:
globalMap.put("MyDate", StingHandling.LEFT(row3.ReportDate, 11));

It should works.

Regards,
TRF
Anonymous
Not applicable
Author

Does stringhandling.left just take the 11 chars from the left?
I'd prefer to store it as dd-MMM-yy in string or date format as I can parse it easily enough in tMap. I was a bit surprised the formatting changed as I had the output schema defined as date dd/mmm/yy but at least I know its getting detected as a date
How would I re-enforce the required structure on the string I store in  globalMap.put("MyDate", row3.ReportDate);
Java isn't my strong point