If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Other PC Databases > DateDiff (Foxpro - oh no!)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-10-07, 04:56
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Smile 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
Twitter | Blog
Reply With Quote
  #2 (permalink)  
Old 05-10-07, 05:19
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
__________________
George
Twitter | Blog

Last edited by gvee; 05-10-07 at 05:22. Reason: Slight modification (if statement)
Reply With Quote
  #3 (permalink)  
Old 05-10-07, 06:54
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
And after all that, look what I stumble over:
Code:
DayDif(<First Date>, <Second Date>)
Similar functions available for month, week & year.
*sigh*
__________________
George
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 05-30-07, 02:27
RedAxl RedAxl is offline
Registered User
 
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"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On