| 
					
	
	 I'm trying to parse the below date using the DateParser::parseFormatted method but I'm not having any luck. 
 I can use this method but for a date string formatted dd/mm/yyyy it outputs the wrong year. How do I correct this. 
 d.year should equal 2016 but instead I get 2020 because the only date the date parser seems to take is dd/mm/yy 
 
 #include <iostream> 
#include <ql/quantlib.hpp> 
#include <ql/utilities/dataparsers.hpp> 
using namespace std; 
using namespace QuantLib; 
int main() 
{ 
    Calendar cal = Australia(); 
    // convert a string to a date. 
    string mydate = "05/08/2016"; 
    const Date d = DateParser::parseFormatted(mydate,"%d/%m/%y"); 
    cout << "The year of this date is: " <<  d.year() << endl; 
} 
------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users  | 
			
| 
					
	
	 Use %Y (capital Y) for 4-digits year.  The parser uses Boost.Date internally; the complete reference for the format is at <http://www.boost.org/doc/libs/1_61_0/doc/html/date_time/date_time_io.html#date_time.format_flags>. Luigi On Wed, Sep 7, 2016 at 12:35 PM Domonic Tom <[hidden email]> wrote: 
 ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users  | 
			
| 
					
	
	 Thanks very much.. This will be very useful. From: Luigi Ballabio <[hidden email]> 
Sent: Wednesday, 7 September 2016 9:03 PM To: Domonic Tom; [hidden email] Subject: Re: [Quantlib-users] DateParser::parseFormatted(string, format) - Parsing dd/mm/yyyy ? Use %Y (capital Y) for 4-digits year.  The parser uses Boost.Date internally; the complete reference for the format is at <http://www.boost.org/doc/libs/1_61_0/doc/html/date_time/date_time_io.html#date_time.format_flags>.
 
Luigi 
On Wed, Sep 7, 2016 at 12:35 PM Domonic Tom <[hidden email]> wrote: 
 ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users  | 
			
| Free forum by Nabble | Edit this page | 
	
	
		