-2

please i'm having problems resolving a function about a program in Visual Fox Pro.

I need to make a rounding down every 20 minutes in decimal. For example: if i recive 19 minutes (0.316) y need return 0 minutes. if i get between 0-19 minutes, return 0 minutes if i get between 20-39 minutes, return 20 minutes if i get between 40-59 minutes, return 40 minutes if i get between 60-79 minutes, return 60 minutes

i was thinking use ROUND() but i don't know how because "Round" Approaches to the nearest decimal.

thanks in advance.

SeWaNsX
  • 87
  • 2
  • 8
  • Am using this, but if want round 500 minutes...? IIF(VAR1>0,IIF(BETWEEN(VAR1,0,0.3166),0,IIF(BETWEEN(VAR1),0.3333,0.8166),0.3333,0)),0) – SeWaNsX Jun 20 '16 at 17:20

3 Answers3

1

Here's a small prg I made that will hopefully help you or at least start you in the right direction.

lnStart             = 0
lnEnd               = 20
lnReceivedMinutes   = 500
llNotDone           = .T.

IF lnReceivedMinutes > 0
    DO WHILE llNotDone
        IF BETWEEN(lnReceivedMinutes, lnStart, lnEnd)
            llNotDone = .F.
            MESSAGEBOX(ALLTRIM(STR(lnStart)) + " Minutes")
        ELSE
            lnStart = lnStart + 20
            lnEnd = lnEnd + 20
        ENDIF
    ENDDO
ENDIF

I check to see if the value received is between my lnStart and lnEnd. If it is not then I check for the next 20 minutes.

ShawnOrr
  • 1,249
  • 1
  • 12
  • 24
1
roundedMinutes = Floor( m.myMinute / 20 ) * 20

For example:

Create Cursor SampleMin (minutes i, rounded i)
Local ix
For ix = 1 To 600
    Insert Into SampleMin ;
        (minutes, rounded) ;
        values ;
        (m.ix, Floor(m.ix/20) * 20)
Endfor

Locate
Browse
Cetin Basoz
  • 22,495
  • 3
  • 31
  • 39
1

Cetin Basoz gave correct answer

roundedMinutes = Floor( m.myMinute / 20 ) * 20

I have checked myself

A.Z. Soft
  • 526
  • 11
  • 12