#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Dates import

i have 2 files, one create a txt file, and export a cell value with a date.
6-12-2006
The second file import txt file, and read the date field, and change
12-6-2006.

How can resolve this question?

Thank you in advance.
--
Rui Santos
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 95
Default Dates import

If you use the wizard to open/import the text file, on the last screen you
can go field by field selecting basic formating options. You can select you
date fields, and mark if you want them imported as MDY or DMY.

Hope this helps,
Miguel.

"rmcsantos" wrote:

i have 2 files, one create a txt file, and export a cell value with a date.
6-12-2006
The second file import txt file, and read the date field, and change
12-6-2006.

How can resolve this question?

Thank you in advance.
--
Rui Santos

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Dates import

I import the file, by an macro.
++++
Private Sub import_ficheiro_Click()
Dim fs, a As Object
Dim linha(23), linha_lida(23, 8), mystring, historico_caminho_destino,
origem_caminho As String
Dim timedate As Date
Dim filetoopen As Variant
Dim i, caracter, col_escrita, rwindex, colindex, linha_disp, linha_escr As
Integer
historico_caminho_destino = "\\anubis\Users\TimeSheet\history\"
origem_caminho = "\\anubis\Users\TimeSheet"
filetoopen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
If filetoopen = False Then
Exit Sub
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(filetoopen, 1)
For i = 1 To 23
linha(i) = a.readline
Next i
timedate = Left(Right(filetoopen, 14), 10)
If linha(1) = "Ja Importado" Then
MsgBox "Ficheiro já importado!"
a.Close
Exit Sub
End If
col_escrita = 1
linha_disp = Worksheets("BD_horas").Range("linha_disp").Value
For i = 1 To 23
col_escrita = 1
For caracter = 1 To Len(linha(i))
mystring = Mid(linha(i), caracter, 1)
If mystring < ";" Then
linha_lida(i, 1) = linha_lida(i, 1) & mystring
Else
If col_escrita < 1 Then
Else
If linha_disp = 1 Or i = 1 Then
linha_disp = linha_disp + 1
End If
linha_escr = i + linha_disp
If i = 3 Then
linha_escr = linha_escr - i + 2
End If
End If
If col_escrita = 6 Then
If linha_lida(i, 1) = "" Then
Exit For
Else
linha_lida(i, 1) = linha_lida(i, 1) / 1
End If
End If
Worksheets("BD_Horas").Cells(linha_escr, col_escrita).Value =
linha_lida(i, 1)
linha_lida(i, 1) = ""
col_escrita = col_escrita + 1
linha_disp = Worksheets("BD_horas").Range("linha_disp").Value
End If
Next caracter
If linha_disp = 1 Or i = 1 Then
Worksheets("BD_Horas").Cells(linha_escr, 8).Value = timedate
Else
Worksheets("BD_Horas").Cells(linha_escr - 1, 8).Value = timedate
End If
Next i
a.Close
Set fs = CreateObject("Scripting.FileSystemObject")
fs.movefile filetoopen, historico_caminho_destino
End Sub
++++


--
Rui Santos


"Miguel Zapico" wrote:

If you use the wizard to open/import the text file, on the last screen you
can go field by field selecting basic formating options. You can select you
date fields, and mark if you want them imported as MDY or DMY.

Hope this helps,
Miguel.

"rmcsantos" wrote:

i have 2 files, one create a txt file, and export a cell value with a date.
6-12-2006
The second file import txt file, and read the date field, and change
12-6-2006.

How can resolve this question?

Thank you in advance.
--
Rui Santos

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 95
Default Dates import

One solution can be to split the variable timedate in month, day and year,
and use them instead. Something like:
dateday = left(timedate, 2)
datemonth = mid(timedate, 4, 2)
dateyear = right(timedate, 4)
And then print them in the desired order instead of the timedate variable.

Hope this helps,
Miguel.

"rmcsantos" wrote:

I import the file, by an macro.
++++
Private Sub import_ficheiro_Click()
Dim fs, a As Object
Dim linha(23), linha_lida(23, 8), mystring, historico_caminho_destino,
origem_caminho As String
Dim timedate As Date
Dim filetoopen As Variant
Dim i, caracter, col_escrita, rwindex, colindex, linha_disp, linha_escr As
Integer
historico_caminho_destino = "\\anubis\Users\TimeSheet\history\"
origem_caminho = "\\anubis\Users\TimeSheet"
filetoopen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
If filetoopen = False Then
Exit Sub
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(filetoopen, 1)
For i = 1 To 23
linha(i) = a.readline
Next i
timedate = Left(Right(filetoopen, 14), 10)
If linha(1) = "Ja Importado" Then
MsgBox "Ficheiro já importado!"
a.Close
Exit Sub
End If
col_escrita = 1
linha_disp = Worksheets("BD_horas").Range("linha_disp").Value
For i = 1 To 23
col_escrita = 1
For caracter = 1 To Len(linha(i))
mystring = Mid(linha(i), caracter, 1)
If mystring < ";" Then
linha_lida(i, 1) = linha_lida(i, 1) & mystring
Else
If col_escrita < 1 Then
Else
If linha_disp = 1 Or i = 1 Then
linha_disp = linha_disp + 1
End If
linha_escr = i + linha_disp
If i = 3 Then
linha_escr = linha_escr - i + 2
End If
End If
If col_escrita = 6 Then
If linha_lida(i, 1) = "" Then
Exit For
Else
linha_lida(i, 1) = linha_lida(i, 1) / 1
End If
End If
Worksheets("BD_Horas").Cells(linha_escr, col_escrita).Value =
linha_lida(i, 1)
linha_lida(i, 1) = ""
col_escrita = col_escrita + 1
linha_disp = Worksheets("BD_horas").Range("linha_disp").Value
End If
Next caracter
If linha_disp = 1 Or i = 1 Then
Worksheets("BD_Horas").Cells(linha_escr, 8).Value = timedate
Else
Worksheets("BD_Horas").Cells(linha_escr - 1, 8).Value = timedate
End If
Next i
a.Close
Set fs = CreateObject("Scripting.FileSystemObject")
fs.movefile filetoopen, historico_caminho_destino
End Sub
++++


--
Rui Santos


"Miguel Zapico" wrote:

If you use the wizard to open/import the text file, on the last screen you
can go field by field selecting basic formating options. You can select you
date fields, and mark if you want them imported as MDY or DMY.

Hope this helps,
Miguel.

"rmcsantos" wrote:

i have 2 files, one create a txt file, and export a cell value with a date.
6-12-2006
The second file import txt file, and read the date field, and change
12-6-2006.

How can resolve this question?

Thank you in advance.
--
Rui Santos

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
working out quarters (three-month periods) between two dates [email protected] Excel Worksheet Functions 1 May 17th 06 10:27 AM
formula to add dates. S S Excel Worksheet Functions 8 April 5th 06 07:53 PM
Pre-1900 dates Richard Gadsden Excel Discussion (Misc queries) 1 March 26th 06 12:46 AM
How can I import dates from an Excel spreadsheet into a calendar . HazMatFool Excel Worksheet Functions 0 February 26th 05 04:23 PM
Formating Dates for production schedule dpl7579 Excel Discussion (Misc queries) 1 January 11th 05 08:43 PM


All times are GMT +1. The time now is 09:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"