繁体   English   中英

日期/时间比较

[英]Date/time comparison

我想找到记录之间具有最小日期/时间的日期/时间。 在具有多条记录的表中。

外汇。

 - 11/11-15 13:00
 - 11/11-15 15:30
 - 11/11-15 16:45 <= (find this record)
 - Timenow (11/11-15 18:33) the current record i want to create but i need to compare the old dates with.

我无法创建逻辑,帮助!

谢谢

您可以创建一个返回两个日期之间差异的函数,通过该函数运行所有可能的日期,然后选择最小的差异。

像这样的东西(伪c代码)

 int array[numdates];
 for (int i=0;i<numdates;i++)
     array[i]=compareDates(date[index], currentDate);

然后您可以对数组进行排序,使最小的数字位于开头(或结尾)并返回该数字。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM