I have a table similar to this one:
------------------------------
| id | fecha |
------------------------------
| 1 | 2018-06-18 14:30:00 |
| 2 | 2018-06-18 14:31:40 |
------------------------------
The important thing is in the date, since I need it to make another query.
In Start I get the last record of the table with the Ultimate function :
public static DataTable Ultimo()
{
DataTable DtResultado = new DataTable("ultimo");
NpgsqlConnection SqlCon = new NpgsqlConnection(Conexion.Cn);
NpgsqlCommand SqlDat = new NpgsqlCommand(String.Format("select * from " + table + " order by fecha desc limit 1"), SqlCon);
SqlCon.Open();
NpgsqlDataReader dr = SqlDat.ExecuteReader(CommandBehavior.CloseConnection);
DtResultado.Load(dr);
dr.Close();
SqlDat.Dispose();
SqlCon.Close();
return DtResultado;
}
So almost everything ok , since the date returns me well on my pc: 2018-06-18 14:31:40
, but in another I return: 2018-06-18 2:31:40 p.m.
.
The fact is that I need all the data of that date so that said fecha
sent it to the PorFechaExacta function as I get in the previous query:
public static DataTable PorFechaExacta(string date)
{
DataTable DtResultado = new DataTable("fechaExacta");
NpgsqlConnection SqlCon = new NpgsqlConnection(Conexion.Cn);
Console.Write(date);
NpgsqlCommand SqlDat = new NpgsqlCommand(String.Format("select * from " + table + " where date(fecha)='"+date+"'"), SqlCon);
SqlCon.Open();
NpgsqlDataReader dr = SqlDat.ExecuteReader(CommandBehavior.CloseConnection);
DtResultado.Load(dr);
dr.Close();
SqlDat.Dispose();
SqlCon.Close();
return DtResultado;
}
And there's a very long error with title:
ERROR: the time zone