date problem

I’ve a date problem with a xojo 2013 3.3 project.

If in field(0) there is this date “31032015” than in wk_date_cons there will be 01032015.

        ll = Len(fields(0))
        if ll = 8 then
          wk_data_cons.Day = val(Left(fields(0), 2))
          wk_data_cons.Month = val(Mid(fields(0), 3, 2))
          wk_data_cons.Year = val(Mid(fields(0), 5, 4))
        elseif ll = 7 then
          wk_data_cons.Day = val(Left(fields(0), 1))
          wk_data_cons.Month = val(Mid(fields(0), 2, 2))
          wk_data_cons.Year = val(Mid(fields(0), 4, 4))
        else
          // data errata
          wk_codice = "999"
        end if 

For other date it works !!

Any help is apreciate.

Thanks

Luciano

solved !!! I’ve filled before the year and than the month at the end the day.

ll = Len(fields(0))
if ll = 8 then
wk_data_cons.Year = val(Mid(fields(0), 5, 4))
wk_data_cons.Month = val(Mid(fields(0), 3, 2))
wk_data_cons.Day = val(Left(fields(0), 2))
elseif ll = 7 then
wk_data_cons.Year = val(Mid(fields(0), 4, 4))
wk_data_cons.Month = val(Mid(fields(0), 2, 2))
wk_data_cons.Day = val(Left(fields(0), 1))
else
// data errata
wk_codice = “999”
end if

Si Luciano, le date vanno compilate dal grande (anno) al piccolo (secondi) altrimenti possono succedere cose soprendenti :slight_smile:
Questo uno dei motivi per cui nel nuovo framework le date sono immutabili e puoi crearle solo con il costruttore.

Grazie Antonio.