我的数据库中有一个表,其中有两列,一列START_TIME
,另一列END_TIME
。列的类型为VARCHAR2
。
我想选择这两列之间的时差。
要知道这些列包含哪种数据,我已从下面的这些列中选择了数据。
这是SELECT DISTINCT start_time FROM table_name
:
15:20
22.30
16:00
24:00
07:00
06:55
6:45
23:50
6.5
15.20
19:00
0:00
1600
16
19
15:00
6:50
7
15:30
23.50
24
14.75
23
15:45
00:15
这是SELECT DISTINCT end_time FROM table_name
07:00
16:00
24:00
6:45
15:35
07
00
16
08:00
07:20
7.25
15:00
0700
7
15:30
15
06:45
07.00
24
15.30
7:00
23
15:45
00:15
可以做些什么?
答案 0 :(得分:1)
您的数据看起来就像包含各种格式的小时一样。 " 14.75"建议小数点是十进制小时。
我建议将全部转换为十进制小时。所以,像这样:
select (case when col like '%:%'
then cast(regexp_substr(col, '[^:]', 1, 1) as decimal(10, 2)) + cast(right(col, 2) as decimal(10, 2)) / 100
else cast(col as decimal(10, 2))
end)
然后,您可以通过转换两者并获取差异来获得时差 - 您将获得十进制小时数。
答案 1 :(得分:-1)
function getDocumentAsCompressed() {
Office.context.document.getFileAsync(Office.FileType.Compressed, { sliceSize: 65536 /*64 KB*/ },
function (result) {
if (result.status == "succeeded") {
// If the getFileAsync call succeeded, then
// result.value will return a valid File Object.
var myFile = result.value;
var sliceCount = myFile.sliceCount;
var slicesReceived = 0, gotAllSlices = true, docdataSlices = [];
app.showNotification("File size:" + myFile.size + " #Slices: " + sliceCount);
// Get the file slices.
getSliceAsync(myFile, 0, sliceCount, gotAllSlices, docdataSlices, slicesReceived);
}
else {
app.showNotification("Error:", result.error.message);
}
});
}
function getSliceAsync(file, nextSlice, sliceCount, gotAllSlices, docdataSlices, slicesReceived) {
file.getSliceAsync(nextSlice, function (sliceResult) {
if (sliceResult.status == "succeeded") {
if (!gotAllSlices) { // Failed to get all slices, no need to continue.
return;
}
// Got one slice, store it in a temporary array.
// (Or you can do something else, such as
// send it to a third-party server.)
docdataSlices[sliceResult.value.index] = sliceResult.value.data;
if (++slicesReceived == sliceCount) {
// All slices have been received.
file.closeAsync();
onGotAllSlices(docdataSlices);
}
else {
getSliceAsync(file, ++nextSlice, sliceCount, gotAllSlices, docdataSlices, slicesReceived);
}
}
else {
gotAllSlices = false;
file.closeAsync();
app.showNotification("getSliceAsync Error:", sliceResult.error.message);
}
});
}
function onGotAllSlices(docdataSlices) {
var docdata = [];
for (var i = 0; i < docdataSlices.length; i++) {
docdata = docdata.concat(docdataSlices[i]);
}
var fileContent = new String();
for (var j = 0; j < docdata.length; j++) {
fileContent += String.fromCharCode(docdata[j]);
}
// Now all the file content is stored in 'fileContent' variable,
// you can do something with it, such as print, fax...
}