Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 8201
Location: Dubuque, Iowa, USA

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: 6970
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 Can EDCICONV convert EBCDIC to ASCII... natt.sut IBM Tools 3 Fri Nov 17, 2017 8:46 pm
No new posts Comparision with current time arunsoods DFSORT/ICETOOL 5 Thu Nov 09, 2017 10:37 am
This topic is locked: you cannot edit posts or make replies. Comparing current time with the time ... arunsoods SYNCSORT 1 Mon Oct 30, 2017 4:07 pm
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm
This topic is locked: you cannot edit posts or make replies. 00D3003B - time outs in DB2 when invo... chavinash2004 DB2 2 Mon Oct 09, 2017 4:39 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us