is possible to import a Time field using excell buffer
gorvega79
Member Posts: 73
i want to import a time field from a excel file using excell buffer table. if in excel the time field value is 09:30:00, when i import the file, in the excell buffer table value is 0,40486111111111 i think that excell buffer transform the value to a text value. but i need the time...is possible do something.
thank you
thank you
0
Answers
-
try to convert TIME to STRING before you insert in excel buffer tableVarTime := TIME;
ReturnTime := FORMAT(VarTime,0,'<Hours24,2>:<Minutes,2>:<Seconds,2>');
IF ReturnTime = '' THEN
ReturnTime := '00:00:00';0 -
one more question, i have done this:
rExcelBuffer.OpenBook(FileRoot,rExcelBuffer.SelectSheetsName(fileroot));
rExcelBuffer.ReadSheet();
i don´t know where i have to put the code, if i have to put before readsheet how can i change the field format. finally i think that i have to change the function readsheet and put to code in....any observation please
thank yo so much0 -
in these cases, it's easier to put a single quotemark before the time value in your excel column...this will make the data 100% text, and you can import it in nav and do an evaluate (be also aware of your windows decimal and thousand separator)0
-
yes but the problem is that we´re trying to automatize all the processes and is necesary not touch the excel file...i will search. if someone find something please tell me
thank you so much ](*,) ](*,)0 -
if excel file supplier can't change excel file field type to Text before export, than you can solve this problem using ADO (haha, i know it's not a trivial way to do this, but if there is no alternative, it helps you \:D/ )0
-
-
Excell stores the time as a decimal part of a day you just need to convert this from the decimal to the time
If you use the below function in excel and enter you number you will get your time
TIMEVALUE function
Show All
Hide All
Returns the decimal number of the time represented by a text string. The decimal number is a value ranging from 0 (zero) to 0.99999999, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).
Hope this helps
Steve0 -
:shock: really??thank you, i'll test it out! =D>SPost29 wrote:Excell stores the time as a decimal part of a day you just need to convert this from the decimal to the time
If you use the below function in excel and enter you number you will get your time
TIMEVALUE function
Show All
Hide All
Returns the decimal number of the time represented by a text string. The decimal number is a value ranging from 0 (zero) to 0.99999999, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).
Hope this helps
Steve0 -
YES! It is!!!!!!!!
Call the function below as this example for test:
IF TrasformaOreExcelInTime(0.382638889,VariableTimeToReceive) THEN
MESSAGE('%1',VariableTimeToReceive);
Create a function like this:
TrasformaOreExcelInTime(ValoreDecimaleParm : Decimal;VAR ValoreTime : Time) : Boolean
IF (ValoreDecimaleParm < 0) OR (ValoreDecimaleParm > 1) THEN
EXIT(FALSE);
IF (ValoreDecimaleParm = 0) THEN BEGIN
ValoreTime := 0T;
RisultatoEvaluateLoc := TRUE;
END ELSE BEGIN
TotaleMillisecondiLoc := ROUND((86400000 * ValoreDecimaleParm),1,'=');
OreLoc := TotaleMillisecondiLoc DIV 3600000;
Intero2Loc := OreLoc * 3600000;
MillisecondiMinutiLoc := TotaleMillisecondiLoc - Intero2Loc;
MinutiLoc := MillisecondiMinutiLoc DIV 60000;
Intero3Loc := MinutiLoc * 60000;
MillisecondiSecondiLoc := MillisecondiMinutiLoc -Intero3Loc;
SecondiLoc := MillisecondiSecondiLoc DIV 1000;
InteroOreMinutiSecondiLoc := (OreLoc * 10000) + (MinutiLoc * 100) + SecondiLoc;
TestOreMinutiSecondiLoc := FORMAT(InteroOreMinutiSecondiLoc);
if InteroOreMinutiSecondiLoc < 99999 then begin
TestOreMinutiSecondiLoc := '0' + TestOreMinutiSecondiLoc;
end;
RisultatoEvaluateLoc := EVALUATE(ValoreTime,TestOreMinutiSecondiLoc);
END;
EXIT(RisultatoEvaluateLoc);
Declare Local Variable as:
Name DataType Subtype Length
TotaleMillisecondiLoc Integer
MillisecondiMinutiLoc Integer
OreLoc Integer
Intero2Loc Integer
MinutiLoc Integer
MillisecondiSecondiLoc Integer
Intero3Loc Integer
SecondiLoc Integer
InteroOreMinutiSecondiLoc Integer
TestOreMinutiSecondiLoc Text 30
RisultatoEvaluateLoc Boolean
Declare Parameters as:
Var Name DataType Subtype Length
No ValoreDecimaleParm Decimal
Sì ValoreTime Time
Dont forget the return value as boolean!
Sorry, all the variabels are in Italian. I was too lazy to translate!
Bye, bye.
=D> =D> =D> =D> =D> =D> =D> =D> =D>0 -
Here you have example of function reading DATETIME from Excel Buffer table:gorvega79 wrote:i want to import a time field from a excel file using excell buffer table. if in excel the time field value is 09:30:00, when i import the file, in the excell buffer table value is 0,40486111111111 i think that excell buffer transform the value to a text value. but i need the time...is possible do something.
thank youcalcDateTime(DatTimText : Text[100];DatTimText2 : Text[100]) : DateTime ts := ' '; ts[1] := FORMAT(1000.0)[2]; EVALUATE(dat,DatTimText); DatTimText2 := DELCHR(DatTimText2,'<=>',ts); EVALUATE(dec,DatTimText2); i := ROUND(dec,1,'<'); tim := 000000T; tim := tim + ROUND((dec-i)*(1000*60*60*24),1); dt := CREATEDATETIME(dat,tim); EXIT(dt);
The function is taken from Universal Excel Importer from mibuso. In Codeunit99991 you will find the function and how to use it to read DATETIME from Excel Buffer table.Slawek Guzek - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
