所以我有这个查询:
SELECT FD_DATUM_INGEVOERD || ' ' || FT_TIJD_INGEVOERD
FROM BANDZENDINGEN
将日期列和时间列结合在一起,但是我得到了以下结果:
如您所见,我得到了毫秒,但是在原始列中没有时间落后毫秒:
SELECT FT_TIJD_INGEVOERD FROM BANDZENDINGEN
为什么会这样?怎样删除毫秒?
答案 0 :(得分:1)
解决了我的php文件中的问题:
$dateArr = array();
$date = $sfm->fetchAll(PDO::FETCH_COLUMN, 0);
foreach ($date as $row)
{
$new_date = date("Y-m-d h:i:s", strtotime($row));
array_push($dateArr, $new_date);
}
答案 1 :(得分:0)
如果您使用的是 FD_DATUM_INGEVOERD的输入日期 并输入FT_TIJD_INGEVOERD的时间
您可以这样做
select
cast(FD_DATUM_INGEVOERD as date)||' '||substring(cast(FT_TIJD_INGEVOERD as time) from 1 for 8)
FROM BANDZENDINGEN
答案 2 :(得分:0)
仅查询时间时,客户端应用程序将转换为字符串。在这里,它显然不包括亚秒级的部分。将时间值连接到字符串时,它会在服务器上使用与语言环境有关的转换,该转换确实包括亚秒级的部分(这也可能与语言环境有关!)。
有几种可能的解决方案
LEFT
:package com.vaadin.starter.skeleton;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.PWA;
/**
* The main view contains a button and a click listener.
*/
@Route("")
@PWA(name = "Project Base for Vaadin Flow", shortName = "Project Base")
public class MainView extends VerticalLayout {
public MainView() {
ComboBox<ENUM> comboBox = new ComboBox<ENUM>("Number");
comboBox.setItems(ENUM.values());
Binder<Bean> binder = new Binder<>();
binder.setBean(new Bean());
binder.bind(comboBox,Bean::getField,Bean::setField);
Button button = new Button("Check value",
e-> Notification.show("Value in bean is " + binder.getBean().getField()));
add(button,comboBox);
}
public enum ENUM {
ONE,TWO,TREE
}
public static class Bean {
private ENUM field;
public ENUM getField() {
return field;
}
public void setField(ENUM field) {
this.field = field;
}
}
}
SUBSTRING
:LEFT(FD_DATUM_INGEVOERD || ' ' || FT_TIJD_INGEVOERD, 19)
SUBSTRING(FD_DATUM_INGEVOERD || ' ' || FT_TIJD_INGEVOERD FROM 1 FOR 19)
具有SQL正则表达式(Firebird 3),但这在这里实在是太过分了格式化客户端几乎总是更好的选择。