|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
convert years, months to days |
« View previous topic :: View next topic » |
Author |
Message
|
sunny_30 |
Posted: Thu Feb 27, 2014 2:56 pm Post subject: convert years, months to days |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
Is there a way to convert Years, Months to Days in esql ?
Im using INTERVAL datatype to store the # of Years and Months but Im trying to figure how to convert that to days.
I have a requirement to convert XML schema Duration datatype: PnYnMnDTnHnMnS to HHmmss.
I have the StartDateTime in this format: 'yyyy-MM-dd''T''HH:mm:ssZ' |
|
Back to top |
|
 |
Simbu |
Posted: Thu Feb 27, 2014 8:32 pm Post subject: |
|
|
 Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
Have you tried EXTRACT Fn? |
|
Back to top |
|
 |
santhoshramesh |
Posted: Thu Feb 27, 2014 10:59 pm Post subject: |
|
|
Novice
Joined: 26 Feb 2014 Posts: 17
|
As Mr. Simbu said, try Extract function
Sample:
EXTRACT(DAY FROM Source Date) |
|
Back to top |
|
 |
Gralgrathor |
Posted: Fri Feb 28, 2014 1:05 am Post subject: |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
santhoshramesh wrote: |
EXTRACT(DAY FROM Source Date) |
Uh uh.
http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ak05420_.htm?resultof=%22extract%22 wrote: |
EXTRACT(DAY FROM CURRENT_TIME)
fails.
EXTRACT (DAYS FROM DATE '2000-02-29')
calculates the number of days encountered since year 1 to '2000-02-29' and
EXTRACT (DAYOFYEAR FROM CURRENT_DATE)
calculates the number of days encountered since the beginning of the current year but |
_________________ A measure of wheat for a penny, and three measures of barley for a penny; and see thou hurt not the oil and the wine. |
|
Back to top |
|
 |
sunny_30 |
Posted: Fri Feb 28, 2014 6:28 am Post subject: |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
I got it working. Thx for help
My requirement is to calculate 'Hours' elapsed ([Hours]mmss format) since a particular startDate ('yyyy-MM-dd''T''HH:mm:ssZ') till PnYnMnDTnHnMnS period. To convert duration of 'years, months' to exact Days requires a start-date.
I created an INTERVAL variable and stored Years, Months in 'YEAR TO MONTH' subtype. later added this to start-date-Timestamp (ts1) which results in another Timestamp (ts2)
Another INTERVAL variable to store (ts2 - ts1) HOUR results in # of Hours
Thanks |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|