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: 7931
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 DD DUMMY & CPU TIME Nileshkul Testing & Performance analysis 16 Mon Dec 19, 2016 11:35 pm
This topic is locked: you cannot edit posts or make replies. Get a job submitted itself every time... arunsoods JCL & VSAM 3 Tue Nov 22, 2016 4:05 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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