Desktop version

Main > Forum > 1C:Enterprise Platform > Studying 1C:Enterprise platform > Extract substring by separators

Forum

Search UsersRules
Extract substring by separators
#1
Active user
Points:: 0
Joined:: Sep 27, 2011

Hello, colleagues!
I have a problem with date separation. I need to extract the day of month from a string like that 7/6/2012. The problem is that sometimes month and day is of 2 digits and sometimes is of 1. Is there any standard function to split a string by a separator?

Profile
#2
Just came
Points:: 8
Joined:: Apr 2, 2012

Hi!
Try something like this:

Code
DateStr = "7/6/2012"
Str1 = Mid(DateStr, Find(DateStr, "/") + 1);
Day = Mid(Str1, 1, Find(Str1, "/") - 1);

Profile
#3
Active user
Points:: 0
Joined:: Sep 27, 2011

Good, good, good, thanks!

Profile
#4
Just came
Points:: 10
Joined:: Apr 17, 2012

Hello!
I like more this way:

Code
   DateStr = "7/6/2012";
   DateStr = StrReplace(DateStr,"/",Chars.LF);
   Day     = StrGetLine(DateStr,1);
   Month   = StrGetLine(DateStr,2);
   Year    = StrGetLine(DateStr,3);

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.