MS Access 中的 TimeValue() 和 TimeSerial()函数
1. TimeValue()函数:
在 MS Access 中,TimeValue()函数根据给定的字符串返回时间。在这个函数中,字符串将作为参数传递,它会根据字符串返回时间。并且返回时间小时部分将是 0 到 12,分钟和秒部分将是 0 到 59。
句法 :
TimeValue(string)
参数值:
Parameter | Description |
---|---|
string | It is Required. the string can be in the range (00:00:00) to (23:59:59) |
示例 1:
SELECT TimeValue("18:15:38");
输出 :
6:15:38 PM
示例 2:
SELECT TimeValue("5:45:18 PM");
输出 :
5:45:18 PM
2. TimeSerial()函数:
在 MS Access 中,TimeSerial()函数返回指定部分的时间。第一部分是小时,第二部分是分钟,第三部分是秒。小时将在 0 到 23 范围内,分钟将在 0 到 59 范围内,秒将在 0 到 59 范围内。在此函数中,将传递带有分隔列的小时、分钟和秒,并将返回时间。
句法 :
TimeSerial(hour, minute, second)
参数值:
Parameter | Description |
---|---|
hour | required. It will be in the range of 0 to 23. |
minute | required. It will be in the range of 0 to 59. |
second | required. It will be in the range of 0 to 59. |
示例 1:
SELECT TimeSerial(5, 10, 20);
输出 :
5:10:20 AM
示例 2:
SELECT TimeSerial(18-4, 49-24, 18-5);
输出 :
2:25:13 PM