Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Days

Status
Not open for further replies.

Holm78

Programmer
Joined
Mar 5, 2002
Messages
60
Location
SE
Hi all


I have a textbox with a date ex. 2003-05-01
And in another textboxt I want a number for how many days has gone since that date to todays date. in this case
7 days.

Any code examples?

//Holm
 
try the sys(11) function - julian day

?VAL(SYS(11,'08/05/2003'))-VAL(SYS(11,'01/05/2003'))

returns 7

btw - sorry about the british date format

MrF
 
Holm78

Although MrFancyteeth's suggestion might work, a simple substraction between two dates gives you the result in days.

Code:
SET DATE MDY
SET CENTURY ON
Local date1,date2
store date() to date2
store ctod("05/15/2003")
nResult = date2-date1
? nResult && Gives 7




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Try this:

- If your textbox is type of date
?date() - textbox.value

- If your textbox is type of character
?date() - ctod(textbox.value)

Regards

-- AirCon --
 
Ahh..Mike, almost at the same time :-)

Regards

-- AirCon --
 
Thanks for the code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top