date parse
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi, I am trying to parse date from string
I have string where date and numbers embedded like 5/31/20210010
Last 4 digits are numbers which can be either 1,2 ,3 or 4 digits.
I used below to parse it and then thinking to concatenate date for mm/dd/yyyy and number in separate column.
(\d+)\/(\d+)\/(\d{4})(\d+)
Is their any better way to solve it?
Solved! Go to Solution.
- Labels:
- Parse
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Although you say the number part at the end can vary in length, as long as your date format before that is always consistent then that looks like a perfectly reasonable way of doing it! There are obviously other ways but I wouldn't say there's a problem with this unless then pattern of the actual date part can change.
Only thing I'd mention is that, if you want to discard of the number on the end, just drop the last capture group i.e. finish the expression at (\d{4}).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Yes. I was just exploring if there is way to avoid concatenate as I am extracting mm, dd, yyyy and number in separate columns.
Can we read string backwards using regex? i..e if I want to read last 4 digit only. I know, its valid only if it;s fixed for 4 char only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I think that you're looking for date time specifiers as:
DateTimeParse(%m/%d/%Y)
For the Last digits...
REGEX_Replace([Field1], ".*\/\d{4}(\d+)", '$1')
This regular expression finds the remaining digits after /9999 a slash followed by 4 digits. All remaining digits are captured.
Cheers,
Mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
If I'm understanding your ask properly then you just want the date part in one column and then the number in another? Rather than a day, month, year and number column? If so, you just need to include the whole date part in one capture group:
(\d+\/\d+\/\d{4})(\d+)
You can then parse the date by using the dateparse function highlighted by @MarqueeCrew above!
![](/skins/images/2A479D0ADEFDAA8078B5B9F489A80DDD/responsive_peak/images/icon_anonymous_message.png)