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

text file - date problem

Status
Not open for further replies.

Oostwijk

Technical User
Oct 19, 2003
82
0
0
NL
I've got a textfile, which contains lines like these:

3-4-03 5:42:30
13-9-03 11:26:00
3-4-03 6:07:16
5-5-99 22:22:00
22-5-03 6:27:48
27-5-03 23:49:06
20-2-03 3:42:12
9-7-02 5:56:34
8-5-03 5:01:44
19-11-03 3:25:56
14-5-03 22:51:50
11-3-03 4:45:28
29-4-03 6:01:56
2-6-03 10:40:54
29-4-03 6:14:38
30-9-03 19:03:00
8-11-03 12:27:48
6-12-03 4:16:46
9-7-02 6:01:52
11-8-03 14:38:50
27-8-03 5:56:10
27-8-03 5:56:10
11-8-03 8:54:12
6-12-03 3:37:52
10-12-03 3:25:04
29-4-03 6:05:18
29-4-03 6:09:58
11-8-03 8:54:18
11-8-03 8:54:24
10-7-03 19:22:32
14-5-03 16:19:32
27-11-02 20:21:42
27-11-02 20:21:42
10-1-01 12:23:58
12-10-02 14:22:24
27-8-03 5:56:10
27-8-03 5:56:06
27-8-03 5:56:10
27-8-03 5:56:06

I read this text file line by line, how can I put the date (not the time) in a variable named Thatday and stript of both the
- characters (the minus characters) ?
 

Have you read FAQ222-2244? Especially Item 15?

Now if you are using Line Input #FileNumber, Variable then ...
[tt]
MyDate = Left(Variable, InStr(1, Variable, " ") - 1)
MyDate = Replace(MyDate, "-", "")
[/tt]

Good Luck

 

Does this work for you ?

Thatday = Replace(Left(myrec, InStr(myrec, " ") - 1), "-", "")
 
Option Explicit

Dim ThatDay As String

' 27-8-03 5:56:06
' I read this text file line by line, how can I put the date (not the time)
' in a variable named Thatday and stript of both the
' - characters (the minus characters) ?

Private Sub Command1_Click()
Dim strLine As String
Dim char As String
strLine = "27-8-03 5:56:06"
MsgBox strLine
char = InStr(1, strLine, Chr(32))
ThatDay = Left(strLine, char)
ThatDay = Replace(ThatDay, Chr(45), vbNullString)
MsgBox ThatDay
End Sub
 
I notice that you haven't found any of the answers to any of your 40 questions helpful. faq222-2244 may help you get better answers, or (if you are getting what you need) how to properly acknowledge them.

For this one try:

strLine = "27-8-03 5:56:06"
Thatday = format (strLine,"dd mm yy")

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top