Re: How to change Database Data Type "DATE" to Quantlib Data Type "Date"?
Posted by
Guowen Han on
Dec 09, 2010; 2:03pm
URL: http://quantlib.414.s1.nabble.com/How-to-change-Database-Data-Type-DATE-to-Quantlib-Data-Type-Date-tp7555p7556.html
First convert the database date to iso
format (either yyyymmdd or yyyy-mm-dd),
inline
Date DateOf(const std::string& date){
size_t length = date.length();
// you may want additional check
here
if (length != 8 && length
!= 10)
throw std::runtime_error("Note
a valide ISO date format!");
short year, month, day;
try{
if (length == 8) { //
'yyyymmdd' format
year = boost::lexical_cast<short>(date.substr(0,4));
month = boost::lexical_cast<short>(date.substr(4,2));
day = boost::lexical_cast<short>(date.substr(6,2));
} else { // 'yyyy-mm-dd'
format
year = boost::lexical_cast<short>(date.substr(0,4));
month = boost::lexical_cast<short>(date.substr(5,2));
day = boost::lexical_cast<short>(date.substr(8,2));
}
return Date(day, Month(month),
year);
} catch (boost::bad_lexical_cast&
e){
throw;
}
}
Hi guys,
How could I change the Oracle Database
data type “DATE” to Quantlib Data Type “Quantlib::Date”?
During debug, I found the first one is
a double type, but second one is a Class.
Thank you for any help------------------------------------------------------------------------------
This SF Dev2Dev email is sponsored by:
WikiLeaks The End of the Free Internet
http://p.sf.net/sfu/therealnews-com_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
_____________________________________________________________
DTCC DISCLAIMER: This email and any files transmitted with it are
confidential and intended solely for the use of the individual or
entity to whom they are addressed. If you have received this email
in error, please notify us immediately and delete the email and any
attachments from your system. The recipient should check this email
and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted
by this email.------------------------------------------------------------------------------
This SF Dev2Dev email is sponsored by:
WikiLeaks The End of the Free Internet
http://p.sf.net/sfu/therealnews-com_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users