Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
Crystal Reports e reportistica
Convertire stringa in time
venerdì 27 maggio 2005 - 15.04
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
stee85
Profilo
| Senior Member
299
messaggi | Data Invio:
ven 27 mag 2005 - 15:04
Ciao a tutti,
devo creare una formula che mi crei la somma di tre campi stringa (il contenuto di queti campi sono tempi es. 10:05). Il risultato che devo ottenere è un'orario
grazie mille
freeteo
Profilo
| Guru
6.542
messaggi | Data Invio:
mar 31 mag 2005 - 00:22
ciao,
puoi sfruttare la funzione TimeSerial di cristal che accetta 3 parametri ore , min ,sec e lui ti restituisce il valore "temporale" tipo:
TimeSerial (0, 100, 0) = 1.40 cioe' 1 ora e 40 min
cosi tu trasformi in numero il campo stringa, li sommi e poi glielo dai in pasto alla funzione...
spero sia quello che ti serviva
ciao
stee85
Profilo
| Senior Member
299
messaggi | Data Invio:
mar 31 mag 2005 - 09:28
ciao teo,
ho provato a scrivere così:
TimeSerial ({Rec.RecHto})-TimeSerial ({Rec.RecHfr})-TimeSerial({Rec.RecHst})
solo che mi dice "argomenti insufficenti per questa funzione"
Solo che il tempo è salvato dentro alla campo stringa Rec.RecHto , Rec.Rec...
stee85
Profilo
| Senior Member
299
messaggi | Data Invio:
mar 31 mag 2005 - 10:00
ho provato a spezzare ore minuti e sec ma adesso dice che l'ultima riga non fa parte della formula
if {Rec.RecInm}= "H" then
stringVar min := Right ({Rec.RecHto},2);
stringVar ore := 0;
if Length ({Rec.RecHto})=4 then
ore=Left ({Rec.RecHto},1)
else
ore=Left ({Rec.RecHto},2)
TimeSerial (ToNumber (ore),ToNumber (min),0)
freeteo
Profilo
| Guru
6.542
messaggi | Data Invio:
mar 31 mag 2005 - 10:14
ciao,
ce qualche problema di ";" mi sembra alla fine dell'if, sono le cose che fanno impazzire anche me della sintassi di crystal ;-)
il resto dovrebbe andare bene...
ciao
stee85
Profilo
| Senior Member
299
messaggi | Data Invio:
mar 31 mag 2005 - 10:31
si effettivamente bastava un ; ora però quando lancio la pagina mi dice:
"Errore nel file C:\Inetpub\wwwroot\Sisco_Test\crRec.rpt: Errore nella formula <ore_tariffa>. 'stringVar ore_Hto := "0"; ' Stringa non numerica. "
il codice completo della formula è questo:
stringVar ore_Hto := "0";
stringVar ore_Hfr := "0";
if {Rec.RecInm}= "H" then
stringVar min_Hto := Right ({Rec.RecHto},2);
if Length ({Rec.RecHto})=4 then
ore_Hto=Left ({Rec.RecHto},1)
else
ore_Hto=Left ({Rec.RecHto},2);
stringVar min_Hfr := Right ({Rec.RecHto},2);
if Length ({Rec.RecHto})=4 then
ore_Hfr=Left ({Rec.RecHfr},1)
else
ore_Hfr=Left ({Rec.RecHfr},2);
TimeSerial (ToNumber (ore_Hto),ToNumber (min_Hto),0)-TimeSerial (ToNumber (ore_Hfr),ToNumber (min_Hfr),0)- ToNumber ({Rec.RecHst})
grazie
stee85
Profilo
| Senior Member
299
messaggi | Data Invio:
mer 8 giu 2005 - 08:50
ehi nessuno sa perchè mi da questo errore :(
freeteo
Profilo
| Guru
6.542
messaggi | Data Invio:
mer 8 giu 2005 - 09:36
ciao,
a occhio probabilmente c'e' 1 record che non contiene il valore come se lo aspetta, ovvero dal left.. che fai sul campo non risulta 1 numero percui il metodo "tonumber" non riesce a convertirlo in numero...
cmq prova a fare filtro con 1 paio di record che sai che siao apposto di sicuro cosi' vedi se la formula funziona,e poi indaghi...
ciao
ps: ma tu non hai 1 campo con dentro i minuti? se lo passi direttamente alla timeserial mettendo:
timeserial( 0,campoMinutiFrom,0 ) ti rtorna valori corretti? poi fai:
timeserial( 0,campoMinutiTo,0 ) - timeserial( 0,campoMinutiFrom,0 ) e cosa torna?
stee85
Profilo
| Senior Member
299
messaggi | Data Invio:
mer 8 giu 2005 - 10:23
ok allora ho provato a scrivere così:
(sintassi Basic)
shared t as time
dim ore as number
dim min as number
if {Rtr.RtrA_R}=true then
min=tonumber(Right ({Trp.TrpDtm},2))
if Len ({Trp.TrpDtm})=4 then
ore=tonumber(left ({Trp.TrpDtm},1 ))
else
ore=tonumber(left({Trp.TrpDtm},2))
end if
t=timeserial(ore,min,0)
else
t=timeserial(ore,min,0)
end if
formula = t
e funziona, se Rtr.RtrAR=true mi scrive il risultato giusto trasformato in tempo
mentre se scrivo così:
shared t as time
dim ore as number
dim min as number
if {Rtr.RtrA_R}=true then
min=tonumber(Right ({Trp.TrpDtm},2))
if Len ({Trp.TrpDtm})=4 then
ore=tonumber(left ({Trp.TrpDtm},1 ))
else
ore=tonumber(left({Trp.TrpDtm},2))
end if
t=timeserial(ore,min,0)+tonumber({Trp.TrpDtm})
else
min=tonumber(Right ({Trp.TrpDtm},2))
if Len ({Trp.TrpDtm})=4 then
ore=tonumber(left ({Trp.TrpDtm},1 ))
else
ore=tonumber(left({Trp.TrpDtm},2))
end if
t=timeserial(ore,min,0)
end if
formula = t
non funziona mi da sempre questo errore:
Errore nel file C:\Inetpub\wwwroot\Sisco_Test\crRec14.rpt: Errore nella formula <TotOre>. 'shared t as time ' Stringa non numerica.
Analisi dello Stack
[FormulaException: Errore nel file C:\Inetpub\wwwroot\Sisco_Test\crRec14.rpt:
Errore nella formula <TotOre>.
'shared t as time
'
Stringa non numerica.]
.F(String , EngineExceptionErrorID
) +676
.A(Int16 , Int32 ) +537
CrystalDecisions.CrystalReports.Engine.FormatEngine.GetPage(PageRequestContext reqContext) +536
CrystalDecisions.ReportSource.LocalReportSourceBase.GetPage(PageRequestContext pageReqContext) +189
CrystalDecisions.Web.ReportAgent.u(Boolean N) +164
CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e) +108
System.Web.UI.Control.PreRenderRecursiveInternal() +62
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Page.ProcessRequestMain() +1489
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !