Android Question Compare Date

Discussion in 'Android Questions' started by imgsimonebiliato, Jun 4, 2015.

  1. imgsimonebiliato

    imgsimonebiliato Well-Known Member Licensed User

    Hello,
    how can I check if a date is before or after, respect to another?
     
  2. Mahares

    Mahares Well-Known Member Licensed User

    Code:
    If DateTime.DateParse(Date1) > DateTime.DateParse(Date2) Then
     
    Peter Simpson and DonManfred like this.
  3. imgsimonebiliato

    imgsimonebiliato Well-Known Member Licensed User

    Hi,
    yes it is correct, but in this code:

    Code:
    Dim f As Boolean
    Dim d, t As Long
    DateTime.DateFormat = "dd/MM/yyyy"
    d = 
    DateTime.DateParse(aData)
    t = 
    DateTime.Add(DateTime.Now, 001)

    If DateTime.Date(d) = DateTime.Date(t) Then
            f = 
    False
        
    Else
            f = 
    True
    End If
    The variable F is always False.
    Why?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    What is the value of aData?
     
  5. eurojam

    eurojam Well-Known Member Licensed User

    Code:
    Dim f As Boolean
    Dim d, t As Long
    DateTime.DateFormat = "dd/MM/yyyy"
    d = 
    DateTime.DateParse( "07/06/2015")
    t = 
    DateTime.Add(DateTime.Now, 001'this returns F=true because today is 5th
    ' t = DateTime.Add(DateTime.Now, 0, 0, 2) 'this returns F=false because today is 5th + 2 = 7th


    Log(DateTime.Date(d) & " " & DateTime.Date(t))
    If DateTime.Date(d) = DateTime.Date(t) Then
            f = 
    False
        
    Else
            f = 
    True
    End If   

    Log(f)
     
    DonManfred likes this.
  6. imgsimonebiliato

    imgsimonebiliato Well-Known Member Licensed User

    I'm wrong, or your code is the same as I provided?

    The value is like "05/06/2015"
     
  7. eurojam

    eurojam Well-Known Member Licensed User

    Yes, sure it is your code....I've played only with values, changed aData to "07/06/2015" and looked what will happen. I seems that all systems are up and working like they should....:)
     
Loading...