
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Help in converting cron expression into date format
Hi,
I have data column which contains cron expression. I would like to convert into date format when I display it.
Can someone help with the conversion?
For ex. - "0 15 13 28 9 ? 2015" to "2015/09/28, 01:15 PM"
Thanks,
Nili

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here you go:
timestamp(timestamp#('0 15 13 28 9 ? 2015','s mm hh DD M ? YYYY'))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the quick response.
It works for above cron expression, but what should I do for other types of cron expression (daily,monthly,weekly) which has different syntax like
0 15 8 ? * * ( which means daily 8:15 AM)
or
0 30 8 1 * ? ( which means monthly on 1st day at 8:30 AM)
Also,
I am trying to put this in if condition like
if(WildMatch(CRON_EXPRESSION, 's mm hh DD M ? YYYY'), timestamp(timestamp#(CRON_EXPRESSION,'s mm hh DD M ? YYYY')), CRON_EXPRESSION) as converted_cron_expression
then it does not work. It does not convert into Timestamp format. Any idea what am I doing wrong?
Thanks,
Nili


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Nilli,
WildMatch won't help in this case as it is used for the String Comparison & not for format comparison. Rather try using some other string functions like SubstringCount(CRON_EXPRESSION)to identify the no of spaces in between the string. which should help identify the format of the string that you need.
Thanks
Amar
