Hello all, 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 |
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:
------------------------------------------------------------------------------ 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 |
In reply to this post by Pavan Shah-2
You can use the DateParser class in <ql/utilities/dataparsers.hpp>.
For your particolar format, Date d = DateParser::parseISO(str); will work. Luigi On Tue, Dec 11, 2012 at 5:21 PM, 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 |
thank you both very much
I converted using the QuantLib DateParser class. it works.
Pavan On Tue, Dec 11, 2012 at 8:48 AM, Luigi Ballabio <[hidden email]> wrote: You can use the DateParser class in <ql/utilities/dataparsers.hpp>. ------------------------------------------------------------------------------ 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 |
Free forum by Nabble | Edit this page |