Reputation: 11
I need to show the number of hours in a Grid, how ever when I use a method to get all of the columns, the results show the Date.
This is my scenario.
(My Entities)
public class Turno
{
public int Cod_Turno { get; set; }
public string Des_Turno { get; set; }
public string Des_NombreCorto { get; set; }
public DateTime Hor_Inicio { get; set; }
public DateTime Hor_Fin { get; set; }
public bool Flag_Activo { get; set; }
}
This is my Access Layer
public IList<Turno> Listar()
{
var turnos = new List<Turno>();
var comando = _baseDatos.GetStoredProcCommand("HOR_Listar_Turno");
using (var lector = _baseDatos.ExecuteReader(comando))
{
while (lector.Read())
{
turnos.Add(new Turno
{
Cod_Turno = lector.GetInt32(lector.GetOrdinal("Cod_Turno")),
Des_Turno = lector.GetString(lector.GetOrdinal("Des_Turno")),
Des_NombreCorto = lector.GetString(lector.GetOrdinal("Des_NombreCorto")),
Hor_Inicio = new DateTime(lector.IsDBNull(lector.GetOrdinal("Hor_Inicio")) ? 0 : lector.GetOrdinal("Hor_Inicio")),
Hor_Fin = new DateTime(lector.IsDBNull(lector.GetOrdinal("Hor_Fin")) ? 0 : lector.GetOrdinal("Hor_Fin")),
Flag_Activo = lector.GetBoolean(lector.GetOrdinal("Flag_Activo"))
});
}
}
comando.Dispose();
return turnos;
}
Is there a way to get a Time in the Line to get HOR_Inicio
and HOR_Fin
; I only need the hours and minutes.
Upvotes: 0
Views: 110
Reputation: 10055
If you want the hours and minutes as a string you could use DateTime.Now.ToString("HH:mm");
Upvotes: 2