I am in Xamarin.Forms, I can not store the date of a DataPicker in the database. This is the class of the database:
public DateTime Fecha
{
get;
set;
}
public string FechaModificada
{
get
{
return string.Format("{0:dd-MM-yyyy HH:MM}", Fecha);
}
}
And this is the XAML code snippet:
<DatePicker x:Name="HoraFinal"
MinimumDate="1/1/1999"
MaximumDate="1/1/3000"
Grid.Row="2" Grid.Column="0"
HorizontalOptions="Start" VerticalOptions="Center"
DateSelected="Fecha_Selected"
/>
<Entry Text="{Binding Fecha, Source={x:Reference HoraFinal}, Mode=TwoWay}" />
And in the programming part I made an alert to see if I picked up the date well.
//Click en hora
DateTime ultima;
async void Fecha_Selected(object sender, Xamarin.Forms.DateChangedEventArgs e)
{
ultima = e.NewDate;
var fechaMostrar = e.NewDate.ToString("D");
await DisplayAlert("DatePicker", fechaMostrar, "Aceptar");
It picks it up well but then it does not store the date well in the database. Stores with the value 01/01/0001. How do I get the DataPicker date and store it correctly in the database ??????