Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Convert time into corresponding minutes

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
zacharti

New User


Joined: 15 Jun 2006
Posts: 13

PostPosted: Thu Feb 10, 2011 6:26 am    Post subject: Convert time into corresponding minutes
Reply with quote

Hi,

I have a requirement to convert time into its corresponding minutes usig DB2 SQL query in mainframe.

Is there any funtion available that directly converts the time into its corresponding minutes?

For eg: if the time is 13:38, it should be converted into 7838 minutes
(13* 60 +38)

Thanks

Tita
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7992
Location: Bellevue, IA

PostPosted: Thu Feb 10, 2011 6:43 am    Post subject:
Reply with quote

Either you're using a mathematical system I'm not familiar with, or you want something I'm not sure you can get from the system.

13 times 60 is 780
Add 38 for a result of 818

Since there are only 1,440 minutes in a day, if you're wanting minutes elapsed since midnight, the value should range from 0 to 1439.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Feb 10, 2011 12:17 pm    Post subject:
Reply with quote

I would suggest using the function MIDNIGHT_SECONDS and divide the result by 60 to get the minutes count.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Feb 10, 2011 12:24 pm    Post subject:
Reply with quote

no function directly converts hours or days to minutes.

depending upon your time column,

the following scalar functions can combined:

MINUTE can be used to extract the minute portion of a time, date, timestamp datatype

HOUR can be used to extract the hour portion of a time, date, timestamp datatype and when multipled by 60 gives the number of minutes for the hour(s).

so,
SELECT (HOUR(datetime_column type) * 60) + (MINUTE(datetime_column type)) as Number_Of_Mminutes.

you can cast a host variable as a datetime datatype.

but if you are using db2 to calculate minutes of a host variable containing HH:MM you are wasting resources.

or use Kjeld's suggestion, but MIDNIGHT_SECONDS also expects a datetime datatype.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm
No new posts Convert current to hex value gopurs DFSORT/ICETOOL 4 Wed Feb 15, 2017 5:40 am
No new posts CICS transaction slow response time vasanthz All Other Mainframe Topics 3 Thu Jan 19, 2017 1:31 am
No new posts DD DUMMY & CPU TIME Nileshkul Testing & Performance analysis 16 Mon Dec 19, 2016 11:35 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us