sql >> Database teknologi >  >> RDS >> Mysql

Forkert antal forskelsdage mellem 2 datoer med joda-tid?

Du nulstillede ikke millisekunderne :)

prøv med:

    Calendar calToday = Calendar.getInstance();
    calToday.set(Calendar.YEAR, calToday.get(Calendar.YEAR));
    calToday.set(Calendar.MONTH, calToday.get(Calendar.MONTH));
    calToday.set(Calendar.DATE, calToday.get(Calendar.DATE));
    calToday.set(Calendar.HOUR_OF_DAY, 0);
    calToday.set(Calendar.MINUTE, 0);
    calToday.set(Calendar.SECOND, 0);
    calToday.set(Calendar.MILLISECOND, 0); // this is important
    long now = calToday.getTimeInMillis();
    long DiffDays = (sqlDate - now) / (24 * 60 * 60 * 1000);
    Log.e("-->", ""+sqlDate );
    Log.e("-->", ""+now);
    Log.e("-->", ""+(sqlDate - now));
    Log.e("-->", ""+DiffDays);
    Log.e("-->", "====================");


  1. SQL:ORDER BY to kolonner blandet, ikke prioritetsbaseret

  2. Liste over Datetime Format Elements i Oracle

  3. mysql OG klausul i samme kolonne flere gange

  4. Er der noget, der ligner Wamp Server?