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

String help

Status
Not open for further replies.

excalibur78

IS-IT--Management
Jan 3, 2001
66
US
I have a datetime with user name string and I need to parse out the datetime. Sample: 2/7/2003 8:48:04 AM by BBROWN
I deally I just want the date (2/7/2003) out of that string. My patience has been exusted with crystal for the day. Any help would be much appreciated.


Thanks,


David
 
This should give you some ideas:

Code:
StringVar myText:="2/7/2003 8:48:04 AM by BBROWN";
StringVar tmp:= left(myText, instr(myText," ")-1);
cdate (tmp)


Steve Phillips, Crystal Consultant
 
Is the word "by" always there?

If so, just use a formula containing:

left({table.field}, instr({table.field}, " by"))

If not, you can check for the AM or PM using:

If instr({table.field}, "AM") > 0 then
left({table.field}, instr({table.field}, "AM")+1)
else
left({table.field}, instr({table.field}, "PM")+1)

If you want to make a real datetime from either, wrap the formulas with cdatetime(), as in:

cdatetime(left({table.field}, instr({table.field}, " by")))

-k
 
By the way, once you have a real date from it, you can right click it and select format field->Datetime->Customize and format it any way you want, so it can show just the MM/DD/YYYY.

-k
 
I got it thanks a ton everyone. Now I can go home and not have to work late =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top