INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Adding minutes to a Time or Timestamp

Share
okay.

Adding minutes to a Time or Timestamp

Adding minutes to a Time or Timestamp

(OP)
I have tried several attempts to add some number of minutes to a Timestamp and also tried with Time.

For example,
update t1 set timecol = Time(Timestamp(datecol, timecol) + '00:15:00')

TIA.

RE: Adding minutes to a Time or Timestamp

if i well remember there's an integrete function name minute you select and cast to minute and add at the same time the number of minute you wish. I'm not sure all my notes are left at my office have a look if there's a prob
answer me for more explain i'll do my best but not befor wednesday

RE: Adding minutes to a Time or Timestamp

Take a look at the following selection where I added 1440 minutes(1 day) to a timestamp. You should be able to adapt this quite easily for your update statement.

                                                        
db2 => select current timestamp from sysibm.sysdummy1   
                                                        
1                                                       
--------------------------                              
2002-04-23-12.04.52.363938                              
                                                        
  1 record(s) selected.                                 


Add 1440 minutes on to the timestamp

db2 => select current timestamp + 1440 minutes from sysibm.sysdummy1  
                                                                      
1                            
--------------------------   
2002-04-24-12.05.13.308158   
                             
  1 record(s) selected.      
          
Hope this is of use to you.

Greg

RE: Adding minutes to a Time or Timestamp

To add any 'time' to a timestamp:

SELECT CURRENT TIMESTAMP + 1 SECOND
SELECT CURRENT TIMESTAMP + 1 MINUTE
SELECT CURRENT TIMESTAMP + 1 HOUR
SELECT CURRENT TIMESTAMP + 1 DAY
SELECT CURRENT TIMESTAMP + 1 MONTH
SELECT CURRENT TIMESTAMP + 1 YEAR

Same works for subtraction.

Hope this helps

Marc Lodge

RE: Adding minutes to a Time or Timestamp

(OP)
Awesome!  Exactly what I needed.  Can anyone give a newby any tips on how to learn this stuff?

Thanks!

RE: Adding minutes to a Time or Timestamp

Cisco,
SQL as a rule is pretty plain and boring. It can be complicated with JOINs and everything, but once you've learnt it, you don't tend to forget it. The 'functions' on the other hand are a little bit more interesting, and, as you don't tend to use them that often, you forget the format. If you have a bit of time to spare, mess around with the date/time functions eg. write a bit of sql that gives the day number from 1 to 7 from a given date. Or make it a bit hard by trying to get the day name in there instead. Or count the number of rows in a table for a particular year/product/employee where there are more than 10 occurences. Doing this sort of thing with the 'functions' will help you to understand what they are doing, and how you can use them. It should give you a feel for what you can achieve in SQL. Have fun and if you get stuck, post it here; There's a lot of people in this forum who will help out.
Marc

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close