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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to filter data into years....

Status
Not open for further replies.

zaq888

MIS
Jun 2, 2003
46
MY
i have a TData table 4 input data from a log file. how can i filter it up n if the date 03/03/03 means year 2003, the data will be also stored on the T2003 table. N if data belongs to the year 2003 it will go to the T2002, and also the TData

this is the code that i used to enter data to TData table:


Private Sub Timer2_Timer()
Dim strTxtFiles As String
Dim strMdbFiles As String
Dim h As Integer
Dim odb As Database
Dim ors As Recordset
Dim count As Integer
Dim nextLine As String
Dim i, p, nextP As Long

On Error GoTo errorHandler
Set odb = OpenDatabase("C:\database\data.mdb")
Set ors = odb.OpenRecordset("Tdata")

h = FreeFile()
strtxtfile = "c:\temp\ex" & Format$(Now - 1, "YYMMDD") & ".log"
txtFile.Text = strtxtfile
MsgBox strtxtfile
Open strtxtfile For Input As #h
For count = 1 To 4
Line Input #h, nextLine
Next
ors.AddNew
Do While Not EOF(h)
Line Input #h, nextLine

ors.AddNew
i = 0
p = 1

arrNextLine = Split(nextLine, " ")
For intCtr = 0 To UBound(arrNextLine) '- 1
ors.Fields(intCtr).Value = arrNextLine(intCtr)
Next

ors.Update
Loop
Close (h)
Timer2.Enabled = False
main.mdisable.Enabled = False
main.Timer1.Enabled = False
Set ors = Nothing
Set odb = Nothing
insertLogFileForm.Visible = False
recordForm.Show
Exit Sub

errorHandler:
MsgBox Err.Description & vbCrLf & strtxtfile
Timer2.Enabled = False
End Sub



I'm Keep Studying.... please show the way...
Not Good in English
 
I'm not sure from your code where you find a date. Can you show me what the value of nextline is after you do a line input, and tell me what part of the string is the date you're trying to evaluate?

Bob
 
this code is used to read a log files ..
In the log file, data is arangged in delimited way..
there 9 column of data that is separated with space.
e.g data:

the first loop count 1 to 4 is to escape the first 4 lines
then it read data n store it in table "TData" into database..
#Software: Microsoft Internet Information Server 4.0
#Version: 1.0
#Date: 2003-05-04 00:01:52
#Fields: date time c-ip cs-username cs-uri-stem sc-status sc-bytes cs-bytes time-taken "this line is the continuation from the fourth line 'where the data begin
2003-05-04 00:01:52 128.2.222.250 - - 220 0 0 0
2003-05-04 00:06:53 128.2.222.250 - - 220 0 0 0

from this code, it can input data to table TData. my Q is , how can i recognize the first column (date) n if YY=2003 it goes to table T2003 and so on

I'm Keep Studying.... please show the way...
Not Good in English
 
Ok. Assuming that the string variable NextLine contains the string beginning 2003-05-04, for example, you need to do something like this:

dim x as Date
x = cDate(left(Nextline, 10)) 'first 10 chars of nextline which will be the date

Now, Year(x) will give you the year, Month(x) will give you the month, and so on.

Not so tough when you know how. :)

Bob
 
i stil cannot understand... can u show me the right way???

I'm Keep Studying.... please show the way...
Not Good in English
 
Anyone can help me?

I'm Keep Studying.... please show the way...
Not Good in English
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top