C++ API如何写入日期和时间戳

下面这里期望写入日期date和时间戳timestamp:

attachments-2023-09-2lklR0Zk650d4b85a38f9.png但如下所示时间并不是期望的,这怎么调整呢?

attachments-2023-09-KF3ylBVK650d4bcfd6d0d.png


请先 登录 后评论

1 个回答

wale

1. 调用Util::countDays(year,month,day)的返回值填入date,例如:

int days = Util::countDays(2023, 9, 22);

得到days为19622

2. 可以用Util::createTimestamp Util::parseConstant,例如

	Constant* p= Util::createTimestamp(2023, 9, 22, 9, 52, 34, 0);
	Constant* seconds= Util::parseConstant(DT_TIMESTAMP, "2022.09.22T09:52:34");
	cout << seconds->getLong() <<","<< p->getLong()<<endl;


请先 登录 后评论