-1

I am struggling through this date extraction. I have a date like this ("D("yyyy-mm-dd")). I want to get this "yyyy-mm-dd" and I cannot strip ("D(") this also because I have this format in other places so I tried like this first searching the string but I am not sure if I am on right track eg. intabc = istrdate.SearchSubString("D("); so please suggest how can I get this value.

Input is "(D(YYYY-MM-DD))" OUTPUT that I want (YYYY-MM-DD)

What i have done(not correct way I think ) intabc = istrdate.SearchSubString("D(");

  • 4
    Please show your failing code. – Jabberwocky Nov 22 '17 at 08:34
  • Could you add some examples of input and expected output? – MaxPlankton Nov 22 '17 at 08:35
  • You might use [strptime(3)](http://man7.org/linux/man-pages/man3/strptime.3.html) if your system has it. Otherwise your question is C++ standard specific (C++11 has [``](http://en.cppreference.com/w/cpp/header/string) and [``](http://en.cppreference.com/w/cpp/header/chrono)... but older C++ don't) and/or OS specific. Read also [time(7)](http://man7.org/linux/man-pages/man7/time.7.html) at least to understand that time and date is a tricky subject. – Basile Starynkevitch Nov 22 '17 at 08:49
  • 1
    Without more details and without [MCVE] your question is unclear. – Basile Starynkevitch Nov 22 '17 at 08:51

1 Answers1

0

you can use substr() and string::erase() functions in c++98

string str = "\"D(\"yyyy-mm-dd\")";
string result = str.substr(3);  
result.erase(result.end() - 1)
result.erase(result.end() - 1)

if you are using c++11 you can also use string::pop_back() method.

NaWeeD
  • 561
  • 5
  • 15