---
title: "How to Select days between two datetime in android?"  
description: "How to Select days between two datetime in android?"  
author: "Anonymous User"  
published: 2014-11-06  
updated: 2014-11-07  
canonical: https://www.mindstick.com/forum/2534/how-to-select-days-between-two-datetime-in-android  
category: "android"  
tags: ["date", "time", "datetime"]  
reading_time: 1 minute  

---

# How to Select days between two datetime in android?

I have two [datetime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty) 09/01/2014 and 09/10/2014.i want to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) [days](https://www.mindstick.com/articles/157271/how-to-get-cloudways-free-trial-for-14-days-free) between there datetimes. i wrote [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) witch can to change datetime [format](https://www.mindstick.com/forum/162083/how-to-convert-ost-files-into-pst-format)

```
public static String dateFormatterforLukka(String inputDate)        {             String inputFormat = "MM/dd/yyyy";            String outputFormat = "d MMM";             Date parsed = null;            String outputDate = "";            try            {                SimpleDateFormat df_input = new SimpleDateFormat(inputFormat,                        new Locale("en", "US"));                SimpleDateFormat df_output = new SimpleDateFormat(outputFormat,                        new Locale("en", "US"));                  parsed = df_input.parse(inputDate);                outputDate = df_output.format(parsed);            }            catch (Exception e)            {                outputDate = inputDate;            }            return outputDate;        }
```

but i do not know how i can solve my [problem if](https://answers.mindstick.com/qa/50244/how-can-you-fix-the-problem-if-there-is-a-message-saying-the-windows-logon-ui-encountered-a-problem-and-needed-to-close-and-if-the-system-restoring-won-t-work) [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) knows solution please help me\

## Replies

### Reply by Allen Scott

You can try this function:

```
public String getDateDiffString(Date dateOne, Date dateTwo)
{
    long timeOne = dateOne.getTime();
    long timeTwo = dateTwo.getTime();
    long oneDay = 1000 * 60 * 60 * 24;
    long delta = (timeTwo - timeOne) / oneDay;

    if (delta > 0) {
        return "dateTwo is " + delta + " days after dateOne";
    }
    else {
        delta *= -1;
        return "dateTwo is " + delta + " days before dateOne";
    }
}
```


---

Original Source: https://www.mindstick.com/forum/2534/how-to-select-days-between-two-datetime-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
