How do I seperate information using a delimiter

O

OverMyHead

I have a column titled "Shift Start-End" that has the work start and end time
of the employee. The information is formatted as "XX:XX-XX:XX". I need to be
able to seperate the shift end time and put it into a seperate column after I
import the information.

Is this possible? If so, exactly how...PLEASE.
 
D

Dorian

StartTime = LEFT$(ShiftStartEnd,5)
EndTime = RIGHT$(ShiftStartEnd,5)
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
D

Douglas J. Steele

Or, just in case it's not always a 2 digit hour,

StartTime = Left$(ShiftStartEnd, InStr(ShiftStartEnd, "-") - 1)
EndTime = Mid$(ShiftStartEnd, InStr(ShiftStartEnd, "-") + 1)

Also, assumign StartTime and EndTime are Date variables, you might want to
use the CDate function:

StartTime = CDate(Left$(ShiftStartEnd, InStr(ShiftStartEnd, "-") - 1))
EndTime = CDate(Mid$(ShiftStartEnd, InStr(ShiftStartEnd, "-") + 1))
 
O

OverMyHead

I apologize, but is this SQL or a basic query?

Dorian said:
StartTime = LEFT$(ShiftStartEnd,5)
EndTime = RIGHT$(ShiftStartEnd,5)
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
D

Dorian

This is VB code you need to separate out the two portions of the
ShiftStartEnd, you can use the syntax in a SQL query.
e.g.
SELECT LEFT$(ShiftStartEnd,5) As [StartTime] RIGHT$(ShiftStartEnd,5) As
[EndTime] FROM ....
There is no need to create an extra column.
Just separate out the data when you need it (on a form or in a report)
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top