|
-
Nov 7th, 2000, 11:51 AM
#1
Thread Starter
Member
This is a SQL problem but here it goes...
Does anyone know how to extract the time from a datetime datatype?
-
Nov 7th, 2000, 12:00 PM
#2
Lively Member
what do you mean
What exactly do you mean?
To VB or not to VB, that's the question...
-
Nov 7th, 2000, 12:11 PM
#3
Lively Member
as far as I know the datetime field store the date and time in a standard format
e.g. dd/mm/yyyy hh.mm.ss (just an example...I think!)
to get just the time try something along the lines of..
left( variablename, 11)
This will then move 11 chars in and display the rest, which in my example is hh.mm.ss.
You'll need to be sure of the format first and probably need to do some trial and error on it.
You can also use right( variablename, starting point) it that is any easier.
H.
 Just trying to muddle through...
-
Nov 7th, 2000, 12:18 PM
#4
Lively Member
Easier
If all you want to have is the time as hh.mm.ss format, just use the following:
Code:
Dim MyTime As String
MyTime = Format(Time, "Long Time")
And here you go, u don't have to extract and u got the time stored as MyTime!
To VB or not to VB, that's the question...
-
Nov 7th, 2000, 12:19 PM
#5
Hyperactive Member
The date part is to the left of the decimal, and the time part is to the right.
You can use Int(dtmVariable) to strip out the time. Probably, you can use dtmVariable - Int(dtmVariable) to strip out the date.
Or, you can use the DatePart function.
-
Nov 7th, 2000, 12:35 PM
#6
Fanatic Member
There is actually a function in VB6:
TimeValue(<date>)
If you place your variable in here you'll get what you want:
Code:
MyTime = TimeValue(SQLDateTimeVar)
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|