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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to count days from a date? 2

Status
Not open for further replies.

lengoo

IS-IT--Management
Jan 15, 2002
381
GH
Hi All,
I need a little bit of code which allows me to count the number of days since a particular date. eg if the date is November 1, the count will display 21 (since it's the 22nd today).
Is there a quick and easy way of doing this?

Many thanks
 
numDays = dateDiff("d", firstDate, secondDate) -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
use datediff to calculate the difference between the given date and the current date
syntax
DateDiff(interval, date1, date2)

Intervals are
yyyy = year
q = Quarter
m = Month
y = Day of year
d = Day
w = Weekday
ww = Week of year
h = Hour
n = Minute
s = Second

brief example
dateValue = &quot;11/01/2002&quot;
difference = DateDiff(&quot;d&quot;, dateValue, Now)
would return in days 21

common error (and I know because I do it all the time) is to simply place the date values in the wrong arguments. or thus backwards
hope that helps A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
beat me to it
see what happens when you get wordy and type too much. [lol] A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
LOL @ onpnt... [wink] -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
WOW, the response was almost instant, thanks sooo much :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top