Re: dates in quantlib

Posted by Matthew Gline on
URL: http://quantlib.414.s1.nabble.com/dates-in-quantlib-tp13795p13796.html

The QuantLib Date class has a constructor of the form Date (Day d, Month m, Year y)

You should be able to use string::substr to pull each of the year, month, and day from your string, and then atoi to convert them to integers to be passed into the Date constructor.

For a less "DIY" solution, the ctime library has many date manipulation functions to reformat dates, and you may be able to use such a function to extract year, month, and day, or to extract an excel serial number which can also be used to construct a QuantLib Date.


On Tue, Dec 11, 2012 at 11:21 AM, Pavan Shah <[hidden email]> wrote:
Hello all,

 if I have a date in string format such as  "2012-06-25",  how do I convert
 that into a date that QuantLib understands?


Just so we are clear, in this example, 06 = month and 25 = day .

I have to do this conversion on a vector of strings.

 thanks
 Pavan

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users