locked
Problem with DateTime Field in LS project RRS feed

  • Question

  • Hi People,

    i need to when i change a datetime field in my database, updates another field, with only day, month and year, and don't touch time.

    I've tested:

    If Fecha <> Nothing Then
                    HoraFin.Year = Fecha.Year.ToString()
                    HoraFin.Month = Fecha.Month
                    HoraFin.Day = Fecha.Day
                End If

    but, VS, says

    Error 20 La expresión es un valor y, por lo tanto, no puede ser destino de una asignación.


    can anyone cal me to make this working?

    Tuesday, April 5, 2016 6:15 PM

Answers

  • Hi Ivan, I'm not very strong in Spanish anyway indeed Year, Month, Day are all read only properties of any Date variable, you can check it yourself with intellisense, that's why no puede ser destino de una asignación.

    You have to create a new Date and assign it to your HoraFin property.

    HoraFin = New Date(Fecha.Year, Fecha.Month, Fecha.Day)

    Sorry but it's not clear to me what you mean with and don't touch time, if HoraFin already has a time part that you want to keep and modify only day,month, year than use another constructor.

    HoraFin = New Date(Fecha.Year, Fecha.Month, Fecha.Day, HoraFin.Hour, HoraFin.Minute, HoraFin.Second)

    Hope this helps, anyway this question in not about lightswitch at all but basic .NET.


    Marco

    • Marked as answer by Ivan Martinez Saturday, April 9, 2016 2:13 PM
    Tuesday, April 5, 2016 6:39 PM

All replies

  • Hi Ivan, I'm not very strong in Spanish anyway indeed Year, Month, Day are all read only properties of any Date variable, you can check it yourself with intellisense, that's why no puede ser destino de una asignación.

    You have to create a new Date and assign it to your HoraFin property.

    HoraFin = New Date(Fecha.Year, Fecha.Month, Fecha.Day)

    Sorry but it's not clear to me what you mean with and don't touch time, if HoraFin already has a time part that you want to keep and modify only day,month, year than use another constructor.

    HoraFin = New Date(Fecha.Year, Fecha.Month, Fecha.Day, HoraFin.Hour, HoraFin.Minute, HoraFin.Second)

    Hope this helps, anyway this question in not about lightswitch at all but basic .NET.


    Marco

    • Marked as answer by Ivan Martinez Saturday, April 9, 2016 2:13 PM
    Tuesday, April 5, 2016 6:39 PM
  • Thanks!
    Saturday, April 9, 2016 2:13 PM