IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert time into corresponding minutes


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Feb 10, 2011 6:43 am
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts C Compile time time stamps Java & MQSeries 10
No new posts Parallelization in CICS to reduce res... CICS 4
Search our Forums:

Back to Top