Continuing the discussion from Parsing String to Date&Time:
I’ve tried applying the examples in the discussion above, it’s just that it still doesn’t work in my case, even though I think all formats are the same.
this is my configuration in String to Date&Time Node:
And this is my data structure :
28 Jul 2023 21:34:27 +0700
28 Jul 2023 21:30:00 +0700
But the result is empty
Why did it happen?
Hi @veniapputrii ,
I made some tests and the result is about your string from date format. Maybe you can simplify the string for just date using string manipulation and then, use string to date&time node to adjust it as below.
Before: 28 Jul 2023 23:34:47 +0700
regexReplace($Date$,"(\\d+) ([a-zA-Z]+) (\\d+) (\\d+:\\d+:\\d+) (\\++\\d+)","$1/$2/$3")
As you can see, i set just a date for it, and put a slash (/) to split date, month and year as a “real date statement” > 28/Jul/2023.
Then, it works for me to use it:
That’s not the answer that I’d like to pass, but if it resolve your problem, could you apply it from now.
I made some quick tests, and a time/date format in the String to Date&Time node like
28 Jul 2023 23:34:47 +0700
can be converted to a standard date with
You almost had it but you need to specify ‘Date’ (not Date&Time), and use explicit spaces in the format string, as well as the optional indicator (the brackets) to enable it to be converted to a date only.
Hope this helps,
@veniapputrii it seems at least on a Mac with KNIME 4.7.6 this setting seem to work
dd MMM yyyy HH:mm:ss Z
kn_forum_71236_string_to_date_id.knwf (30.2 KB)
Thankyou so much @denisfi , @mlauber71 , @ssq for your help…
But, All the suggestions from you haven’t worked on my node yet. The result is still the same, showing an empty result.
I got the date data from the rss site that I had previously extracted.
Hi @veniapputrii , I think I discovered your problem from “forensically” examining your screenshot:
and comparing it to one I produced using the “same” data.
You have spaces at the start of your dates! Trim them with String Manipulation and then try the solutions again. I think you will find the solutions are correct, but the data was wrong
The post by @mlauber71 has the correct format mask once the dates are trimmed.
Well I have problem with string to time zone… I simplify the date string direct from the source as the workflow added.
rss_date.knwf (17.8 KB)
I saw that the link tag have date structure for the information too:
<![CDATA[ BREAKING NEWS: Bareskrim Polri Tetapkan Panji Gumilang Tersangka Kasus Penistaan Agama hingga Ujaran Kebencian ]]>
<img src="https://media.suara.com/pictures/970x544/2023/08/01/51556-diretipidum-bareskrim-polri-brigjen-pol-djuhandhani-rahardjo-puro.jpg" align="left" hspace="7" width="100" />
<![CDATA[ "Menetapkan saudara PG sebagai tersangka," kata Ramadhan. ]]>
<enclosure length="10240" type="image/jpeg" url="https://media.suara.com/pictures/970x544/2023/08/01/51556-diretipidum-bareskrim-polri-brigjen-pol-djuhandhani-rahardjo-puro.jpg"/>
<![CDATA[ Kasus penistaan agama ]]>
<![CDATA[ ujaran kebencian ]]>
<![CDATA[ Panji Gumilang ]]>
<![CDATA[ pimpinan ponpes al zaytun ]]>
<![CDATA[ bareskrim polri ]]>
<pubDate>Tue, 01 Aug 2023 21:45:52 +0700</pubDate>
So you can work with some solutions here… step by step from my flow:
To remove da Day name before the date.
Remove the timezone
I change the string from the date&time setting as:
dd MMM yyyy HH:mm:ss
That was the result… as I asked you, Do you need all information about the time or just a reference?
can you share your writing expression?
It seems my writing is wrong
HI @veniapputrii ,
There is a strip() function in String Manipulation that you can use, which will remove spaces from beginning and end of the string. This will hopefully do what you need:
Thankyou so much for your help !
I’m looking for similar references to solve my problem, as well as to learn more about the time.
I’ve imported the workflow from you, and step by step I implemented it in my workflow.
When I observed, it turns out that there is a difference in the column names between yours and mine.
yours on the Xpath node
And below is mine on Xpath node
in the Xpath Summary on the Column Name, I gave a column name that doesn’t match the name of the tag in the XML.
which should be the column name : pubdate according to the tag name.
Instead I named it “date”
Maybe there’s a mistake there, that’s why I tried to change the column name according to the tag name, namely “pubdate”
And all the solutions from these discussion mates work fine.
I think column names don’t have to be the same. But, I’m learning something new now.
Thank you very much, everyone !!
Hi @veniapputrii ,
From the XPath, you can set the name for the tag, so normally brings the original value from the path, but if you edit by double click for the field, you can set it as you wish. It helps me to define different names for the original tag for my flow, just it!
I wish it can help you some time…
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.