Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to import actual value, not formatted one from excel
    primarykey
    data
    text
    <p>I'm struggling with importing a date value from an excel file. Importing part works fine! The only problem is its format.</p> <p>In the excel file, all the date values are typed in 'yyyy-mm-dd' format but the cell itself displays it as 'dd-mm-yyyy'. When my program imports values from the excel file, it imports dates as 'dd-mm-yyyy' not the format users actually typed in 'yyyy-mm-dd' - basically, formatted dates.</p> <p>Well, I can manipulate 'dd-mm-yyyy' to 'yyyy-mm-dd' but would like to avoid this solution unless I really have no other ways to do it.</p> <p>Is there any predefined delphi function to reverse 'dd-mm-yyyy' to 'yyyy-mm-dd'? Or are there any special ways to bring the actual unformatted raw dates, not the formatted ones?</p> <p>Unfortunately, changing cell format in excel is not an option here.. :'(</p> <p>Thanks.</p> <p>Update:::</p> <pre><code> ConnectionString :='Microsoft.ACE.OLEDB.12.0;'+ 'Data Source='+filename+';'+ 'Extended Properties="Excel 8.0;'+ 'Imex=2;HDR=NO;;'; } // IMEX = 0: Export mode, 1: Import mode, 2: Linked mode (full update capabilities) ADOQuery1.SQL.Clear; query := 'SELECT * FROM [sheet1$]'; ADOQuery1.SQL.Add(query); ADOQuery1.open; i:=0; while not eof do begin i:= i+1; Cells[0,i] := IntToStr(i); Cells[1,i] := Fields[1].AsString; Cells[2,i] := Fields[2].AsString; Cells[3,i] := Fields[3].Value; // This is the date value I'm trying to import. Cells[4,i] := Fields[4].AsString; Cells[5,i] := Fields[5].AsString; Cells[6,i] := Fields[6].AsString; Cells[7,i] := Fields[7].AsString; Cells[8,i] := Fields[8].AsString; Cells[9,i] := Fields[9].AsString; RowCount := RowCount+1; next; end; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload