Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2005
    Posts
    15

    Unanswered: Rounding up to nearest hour

    Hi Everyone,

    I would like to how to roundup the time for a date/time value.

    e.g 7:30am would be shown as 8:00am. Below I had to format the time fields but I am not sure how to incorporate the round() function.

    Code:
     DECODE(
    	TO_CHAR
    		(
    		TO_DATE
    			(SSRMEET_BEGIN_TIME,'HH24:MI'),'HH:MI pm'
    		)||'-'||
    	       	TO_CHAR
    			(
    			 TO_DATE
    				(SSRMEET_END_TIME,'HH24:MI'),'HH:MI pm'
    			),'-','TBA',
    			TO_CHAR
    				(TO_DATE
    					(SSRMEET_BEGIN_TIME,'HH24:MI'),'HH:MI pm'
    				)||'-'||
    	       		TO_CHAR
    				(
    				TO_DATE
    					(SSRMEET_END_TIME,'HH24:MI'),'HH:MI pm'
    				)
    	)

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    add 30 minutes then truncate the result
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Mar 2005
    Posts
    15
    Hi anacedent,

    I don't think that is going to work but I will try.

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >I don't think that is going to work but I will try.
    It will if properly implemented.
    You are free to post any alternative solution.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jan 2004
    Location
    Issy les Moulineaux, France
    Posts
    24
    Hi,
    you can use trunc as anacedent said, but you can simply use round too.
    Exemple:
    Code:
    select round(sysdate,'HH') from dual;
    Replace sysdate by your date.


    SSRMEET_BEGIN_TIME is a date value or a varchar?. Be careful, you should not use TO_DATE with a date.

    Regards,
    Eric

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •