Important date functions in Oracle BPEL:
Format-dateTime:
This function returns the formatted string of dateTime using
the format provided.
xp20:format-dateTime(dateTime as string, format as string)
- dateTime – The dateTime to be formatted
- format – The format for the output
Format String:-
Format Date Time: Year
Example
|
Expression
|
2012
|
[Y0001]
|
2012
|
[Y]
|
12
|
[Y01]
|
Two Thousand and Twelve
|
[YWw]
|
Format Date Time: Month
Example
|
Expression
|
08
|
[M01]
|
8
|
[M]
|
VIII
|
[MI]
|
August
|
[MNn]
|
AUGUST
|
[MN]
|
Aug
|
[MNn,*-3]
|
AUG
|
[MN,*-3]
|
Format Date Time: Day
Example
|
Expression
|
05
|
[D01]
|
5
|
[D]
|
5
|
[D1]
|
31st
|
[D1o]
|
Tuesday
|
[FNn]
|
Format Date Time: Hour
Example
|
Expression
|
3
|
[h]
|
9
|
[H]
|
08
|
[H01]
|
Format Date Time: Minute
Example
|
Expression
|
03
|
[m01]
|
3
|
[m]
|
Format Date Time: Second
Example
|
Expression
|
09
|
[s01]
|
9
|
[s]
|
Format Date Time: Millisecond
Example
|
Expression
|
257
|
[f001]
|
Format Date Time: AM/PM
Example
|
Expression
|
PM
|
[PN]
|
Am
|
[Pn]
|
Format Date Time: GMT
Example
|
Expression
|
GMT+02:00
|
[z]
|
Example:-
xp20:format-dateTime(xp20:current-dateTime(),"[D01]/[M01]/[Y0001]
[H01]:[m01]:[s01]")
add-dayTimeDuration-from-dateTime:
This function returns a new date time value adding dateTime
to the given duration.
If the duration value is negative, then the resulting value
precedes dateTime.
xp20:add-dayTimeDuration-from-dateTime(dateTime as string,
duration as string)
- dateTime as string – The dateTime to which the function adds the duration, in string format.
- duration as string – The duration to add to the dateTime, or subtract if the duration is negative, in string format.
Duration:-
P1D - a day
P7D - a week
P1M - a month
P1Y1DT1H1S - One
year, one day, one hour and one second
PT5M - five
minutes
Example:-
xp20:add-dayTimeDuration-to-dateTime(xp20:current-date(),
'P1D')
subtract-dayTimeDuration-from-dateTime:
This function returns a new dateTime value after subtracting
duration from dateTime.
If the duration value is negative, then the resultant dateTime
value follows input-dateTime value.
xp20:subtract-dayTimeDuration-from-dateTime(dateTime as
string, duration as string)
dateTime as string
– ThedateTime
from which the function subtracts the duration, in string format.duration as string
– The duration to subtract to thedateTime
, or add if the duration is negative, in string format.
Duration:-
P1D - a day
P7D - a week
P1M - a month
P1Y1DT1H1S - One
year, one day, one hour and one second
PT5M - five
minutes
Example:-
xp20:subtract-dayTimeDuration-from-dateTime(xp20:current-date(),
'P1D')
HI,
ReplyDeleteI want to convert date '01-MAY-2012' to YYYYY-MM-DD format. i used the 'xp20:format-dateTime(procplanebo:EffectiveDate,"[Y0001]-[M01]-[D01]")' but its not working giving me blank value. Plz suggest is sumthng i am doing wrong or how to do this conversion
HI,
Deletesorry its 01-MAY-12
I want to convert date '01-MAY-12' to YYYYY-MM-DD format. i used the 'xp20:format-dateTime(procplanebo:EffectiveDate,"[Y0001]-[M01]-[D01]")' but its not working giving me blank value. Plz suggest is sumthng i am doing wrong or how to do this conversion
HI,
ReplyDeleteI want to convert date '01-MAY-12' to YYYYY-MM-DD format. i used the 'xp20:format-dateTime(procplanebo:EffectiveDate,"[Y0001]-[M01]-[D01]")' but its not working giving me blank value. Plz suggest is sumthng i am doing wrong or how to do this conversion
Can anyone please help and suggest why the below function is not working?
ReplyDeletexp20:add-dayTimeDuration-to-dateTime(xp20:current-date(), 'P5M30S')
During runtime the current time is added with only 5 mins but not the 30 seconds.
Please help and suggest if there is any other way with which we can add mins and seconds.
Thanks in Advance!
Try this
Deletexp20:add-dayTimeDuration-to-dateTime(xp20:current-dateTime(), 'PT5M30S')
2014-01-10T02:35:14-08:00
2014-01-10T02:40:44-08:00
Regards
Albin I
Hi Albin,
DeleteI have tried the function that you mentioned but its still not working for the seconds.
5 minutes are added to the current time but not the seconds.
Is there any problem with this function to work with seconds? Any workaround or suggestions?
it should be PT5M30S
DeleteThanks for the explanation. Really helpful post as always. :)
ReplyDeleteHi,
ReplyDeleteIf you have time included, so the format start with PT, For example to subtrct 2 hours
xp20:subtract-dayTimeDuration-from-dateTime(xp20:current-dateTime() , 'PT2H')
cheers
Khaleel
Thank you for this!!!!
ReplyDeleteI am trying to find difference of two dates in days in bpel. example date1=2016-12-03T17:05:01.853 and date2=2015-12-03T17:05:01.853, I want to find the difference of date1-date2 output as days. pls help
ReplyDeleteHow can i convert date format from DD-MMM-YYYY format to 2014-01-10T02:35:14-08:00 format
ReplyDelete