Forum
Keyword
× Discuss on any other topics

Minus 30 min with current time

  • kda
  • kda's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 597
  • Karma: -23
  • Thank you received: 2

kda created the topic: Minus 30 min with current time

HI all

I want to minus 30 min with current time (say : 17:00 then the result will be 16:30)
How can I reach in infobasic?

Thanks
#21251

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Karma: 2
  • Thank you received: 2

Mallika replied the topic: Minus 30 min with current time

Hi,

To achieve this using ICONV and OCONV

Y.TIME = TIME() ;* Current time
Y.TIME1 = "00:30:00" ;*30mins
Y.TIME1 = ICONV(Y.TIME1,'MTS')
Y.DIFF.TIME = Y.TIME - Y.TIME1
Y.DIFF.TIME = OCONV(Y.DIFF.TIME,'MTS') ;*difference in HH:MM:SS format
#21252

Please Log in or Create an account to join the conversation.

  • VK
  • VK's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • R13|TAFC|jBASE|windoze
  • Posts: 462
  • Karma: 7
  • Thank you received: 63

VK replied the topic: Minus 30 min with current time

Hi
will work unless the current time is, say, 00:15 :)))

CHANGETIMESTAMP() is the better way to handle it I believe...

Cheers
VK
#21253

Please Log in or Create an account to join the conversation.

  • kda
  • kda's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 597
  • Karma: -23
  • Thank you received: 2

kda replied the topic: Minus 30 min with current time

hi

Can you give sample?
#21386

Please Log in or Create an account to join the conversation.

  • VK
  • VK's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • R13|TAFC|jBASE|windoze
  • Posts: 462
  • Karma: 7
  • Thank you received: 63

VK replied the topic: Minus 30 min with current time

Hi
here:
* program test.b
    now = TIME()
    CRT OCONV(now, 'MTS')
    start_time = MAKETIMESTAMP(DATE(), now, '')
    
    time_shift = ''
* Structure of time-shifting array:
* Years^Months^Weeks^Days^Hours^Minutes^Seconds^Milliseconds

    time_shift<6> = -30
    end_time = CHANGETIMESTAMP(start_time, time_shift)
    CRT OCONV(LOCALTIME(end_time, ''), 'MTS')
   

Result:
08:45:04
08:15:04

Cheers
VK
#21387

Please Log in or Create an account to join the conversation.

Time to create page: 0.133 seconds