Normal Topic IN TIME FIELD (Read 918 times)
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
IN TIME FIELD
Apr 8th, 2007 at 8:36pm
Print Post Print Post  
I have one field in my formulario with format HH/MM/SS, but the result appears HH/MM/00, the value of seconds appears: 00, because? This field this with codigo:
If @add and TIME = "" then
{
                                     TIME = @Time
}
I need to know complete time HH/MM/SS in this field.

Renato Piacenti
Manaus - Amazonas - Brazil
Aqui a Floresta esta sendo preservada.
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: IN TIME FIELD
Reply #1 - Apr 8th, 2007 at 8:45pm
Print Post Print Post  
To remain compatible with the Q&A command, @Time does not return seconds. The function @ServerTime() will return hours, minutes, and seconds.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: IN TIME FIELD
Reply #2 - Apr 8th, 2007 at 9:52pm
Print Post Print Post  
hi The Cow

In the on element exit

I changed TIME = @TIME for TIME = @ServerTime (),
but I do not work

Embarrassed
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: IN TIME FIELD
Reply #3 - Apr 8th, 2007 at 9:58pm
Print Post Print Post  
SBasic detects that the destination element is of time type, and converts the string value returning from @ServerTime to match the Q&A rules. If the destination were a string type, it would contain the seconds. I'm considering that this may be a point where we may have to depart from Q&A compatibility.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: IN TIME FIELD
Reply #4 - Apr 8th, 2007 at 11:17pm
Print Post Print Post  
Thank very much, The Cow
work very well after the change of the type of Field.

Renato Piacenti
Manaus - Amazonas - Brazil
Aqui a Floresta esta sendo preservada.
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: IN TIME FIELD
Reply #5 - Apr 9th, 2007 at 9:13pm
Print Post Print Post  
The @ServerTime () function returns String, as to elaborate codigo, (final Time - initial Time), and to get resulted in format HH/MM/SS? Undecided
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: IN TIME FIELD
Reply #6 - Apr 9th, 2007 at 11:14pm
Print Post Print Post  
Quote:
The @ServerTime () function returns String, as to elaborate codigo, (final Time - initial Time), and to get resulted in format HH/MM/SS? Undecided


You might try something like this:
Code
Select All
function DiffTimeWithSeconds(time1 as string, time2 as string) as string
var sec1 as int
var sec2 as int
var diff_sec as int
var secs as int
var mins as int
var hours as int
var a as int
var b as int
var c as int
var result as string

// Get the hours, minutes and seconds from the first time string
a = @ToNumber(@Mid(time1, 1, 2))
b = @ToNumber(@Mid(time1, 4, 2))
c = @ToNumber(@Mid(time1, 7, 2))
// Convert to total seconds
sec1 = (a * 3600) + (b * 60) + c

// Get the hours, minutes and seconds from the second time string
a = @ToNumber(@Mid(time2, 1, 2))
b = @ToNumber(@Mid(time2, 4, 2))
c = @ToNumber(@Mid(time2, 7, 2))
// Convert to total seconds
sec2 = (a * 3600) + (b * 60) + c

// Get the difference in seconds
diff_sec = sec2 - sec1

// Turn the result back into HH:MM:SS
hours = diff_sec / 3600
mins = diff_sec - (hours * 3600)
mins = mins / 60
secs = diff_sec - ((hours * 3600) + (60 * mins))

result = @Str(hours) + ":" + @Str(mins) + ":" + @Str(secs)

return result
end function


// Try it out
var time1 as string
var time2 as string
var result as string

// Get a time string
time1 = @ServerTime()
// Wait 10 seconds
Loiter(10000)
// Get another time string
time2 = @ServerTime()

// Try the function
result = DiffTimeWithSeconds(time1, time2)
writeln(result)

 

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: IN TIME FIELD
Reply #7 - Apr 10th, 2007 at 6:57pm
Print Post Print Post  
Thanks Mark for the attention. This cod was very util
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged