Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I can't get decimal numbers...

Status
Not open for further replies.

srd

Technical User
Oct 16, 2001
14
PT
I have already asked a similiar question... but I just can't solve this... please help.

I have this script to change a record that as been imported as text, but is in fact a period of time in 0(h):00(min):00(secs), and I need it to change it to a "decimal time"... Had one that worked with 00:00 but now, because it was necessary to change it, the script doesn't work. It roundsup the numbers and I would need it to give me at 2 decimal numbers.

SELECT CDbl(Left([DUR CHAM],1)*60)+Mid([DUR CHAM],3,2)+(CLng(Right([DUR CHAM],2)/60)) AS DUR_CHAM_dec INTO chamadas_teste
FROM factura_20030601_20030631;

Many thanks... and sorry for this mess.

sIMAO d.
 
hope this is what you mean. i changed the CLng part to round the right-most two digits into a decimal:


CDbl((Left([DUR CHAM],1)*60)+Mid([DUR CHAM],3,2)+(CInt(((Right([DUR CHAM],2)/60)+0.005)*100))/100)
 
This may do it for you as well depending on how the textfield [DUR CHAM] is set up.

Select Int(((CDate([DUR CHAM])*24)+ 0.005)*100)/100 As DUR_CHAM_dec INTO chamadas_teste
FROM factura_20030601_20030631;


Paul
 
Sorry, in case I didn't understand, you have a couple choices. If [DUR CHAM] = "5:25:53" for 5 hours, 25 minutes and 53 seconds then
Int(((CDate([DUR CHAM])*24)+ 0.005)*100)/100
will return 5.43 hours.
If you want the decimal equivalant of "5:25:53 AM" then you can try
Int(((CDate([DUR CHAM]))+0.005)*100)/100
this would return
.23
for the time value "5:25:53 AM"

Paul

 
how about just doing this?

SELECT [DUR CHAM] INTO chamadas_teste
FROM factura_20030601_20030631;

Dim MyHour as String
Dim MyMinute as String
Dim MySecond as String

MyHour = Hours(Dur_Cham)
MyMinute = Minutes(Dur_Cham)
MySecond = Seconds(Dur_cham)

If Len(MyHour) = 1 Then
MyHour = "0" & MyHour
Endif
etc.....
MyTime = MyHour & MyMinute & MySecond

then today, MyTime = "070703"
or is this too simplistic?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top