Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Smile Unanswered: DateDiff (Foxpro - oh no!)

    Hey all,

    wondering if you can help me, I can't seem to find a function for calculating the difference between two dates in days.

    Any suggestions? I thought there'd be an inbuilt function for this, but so far I've had no luck in finding it!

    -GeorgeV
    George
    Home | Blog

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Ok, here's my reasonable effort/solution
    Code:
    myString = "10/05/2007"
    myString2 = "25/05/2007"
    
    MyDate = CTod(MyString)
    MyDate2 = CTod(MyString2)
    
    x = 0
    If MyDate < MyDate2
    	Do While MyDate + x <> MyDate2
    		x = x + 1
    	EndDo
    Else
    	Do While MyDate + x <> MyDate2
    		x = x - 1
    	EndDo
    EndIf
    
    ? x
    I'm not exactly happy with it, but it'll have do for now.

    Any more ideas are more than welcomed
    Last edited by gvee; 05-10-07 at 06:22. Reason: Slight modification (if statement)
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    And after all that, look what I stumble over:
    Code:
    DayDif(<First Date>, <Second Date>)
    Similar functions available for month, week & year.
    *sigh*
    George
    Home | Blog

  4. #4
    Join Date
    Nov 2004
    Posts
    39

    difference in days between two dates

    Hi Gorge

    In Foxpro, you can simply subtract the two dates directly
    and it will return the difference in days.
    Just store the return value in integer type variable.

    Ex.
    vdate1 = {6/30/2007}
    vdate2 = {7/10/2007}

    vdays = vdate2 - vdate1

    Goodluck!
    Red
    Doing something easily
    what others find difficult is "Talent"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •