Good Morning
I'm doing a date search on android and am having trouble checking the time.It says it gave the syntax error about the time, and another one when I get the date the time is showing less than 3 hours. Can someone help me? follow the code the format of the time I get on the bank is this: 2016-11-23 16: 34: 37,000
public String nomeTabela() {
String Pesquisa = "";
ConexaoDao conexao = new ConexaoDao();
ObjetoConexao objConexao = new ObjetoConexao();
objConexao.db_connect_string = "flexvale.hopto.org:1433";
objConexao.db_name = "FlexPortaCom";
objConexao.db_userid = "sa";
objConexao.db_password = "flextelecom";
Connection conn = conexao.dbConnect(objConexao);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String currentDateandTime = sdf.format(new Date () );
System.out.println(currentDateandTime);
if (conn == null) {
Pesquisa = "Não foi possivel se conectar ao banco de dados";
} else
if (conn != null) try {
Statement statement = conn.createStatement();
String queryString = " Select SUM(DIFERENÇA)as somaMes from TOTALIZADOR WHERE NID = 252 and DATAHORA >= "+currentDateandTime+" and DATAHORA = "+currentDateandTime+" ";
ResultSet rs;
rs = statement.executeQuery(queryString);
if (rs.next()) {
Pesquisa = rs.getString("somaMes");
}
} catch (SQLException e) {
Pesquisa = e.getMessage();
}
return Pesquisa ;
}