Page 1 of 1 1
Topic Options
#73047 - 2003-02-13 12:25 AM Find the number of days between 2 dates
toys4x4boys Offline
Lurker

Registered: 2003-02-12
Posts: 2
Loc: Merseyside, UK
We use Kixtart 4.11 as part of out login script, one of the functions is to check the virus definitions dates to see of they are over 30 days old.

If they are it sends a mail to the helpdesk.

What I need is a way to find the number of days between two dates.

During my search I found this snippet,

$difference=JulianDate(@date)-JulianDate($defdate)

but there is not this feature in 4.11 , or at least not that I can find.

So whats the easiest way to find the number of days between 2 given dates ?

Def Date : 2003/02/05
Client Date : 2003/02/12

[Confused]

Top
#73048 - 2003-02-12 01:45 PM Re: Find the number of days between 2 dates
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The "JulianDate()" function is almost certainly a user defined function - it is not an intrinsic in any version of KiXtart.

There are a number of UDFs for date manupulation in the UDF forum - use the "search" link that you'll find in the top right hand corner of the page and search for "date" in the UDF forum.

Top
#73049 - 2003-02-12 02:42 PM Re: Find the number of days between 2 dates
toys4x4boys Offline
Lurker

Registered: 2003-02-12
Posts: 2
Loc: Merseyside, UK
Ended up with this which works [Eek!]

;----- This compares the virus def date
;----- And the definitions date
;----- Returns the days between the two dates

Function JulianDate($TxDate) ; Assumes 4 digit year, M/D/Y or Y/M/D and / as delimiter
DIM $Year, $Month, $Day, $Pos
$Pos=INSTR($TxDate,"/")
If $Pos=5
$Year=0+SUBSTR($TxDate,1,4)
Else
$Month=0+SUBSTR($TxDate,1,$Pos-1)
EndIf
$TxDate=SUBSTR($TxDate,1+$Pos,10)
$Pos=INSTR($TxDate,"/")
If $Year
$Month=0+SUBSTR($TxDate,1,$Pos-1)
$Day=0+SUBSTR($TxDate,1+$Pos,2)
Else
$Day=0+SUBSTR($TxDate,1,$Pos-1)
$Year=0+SUBSTR($TxDate,1+$Pos,4)
EndIf
$JulianDate=367*$Year-7*($Year+(($Month+9)/12))/4-3*((($Year+($Month-9)/7)/100)+1)/4+275*$Month/9+$Day-678972
EndFunction

$daysbetween=JulianDate(@date)-JulianDate($defdates)

Top
#73050 - 2003-02-12 05:31 PM Re: Find the number of days between 2 dates
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please take a look at the UDF forum as it contains several dat math functions, e.g. DateMath() - Performs mathematical computations on a date or computes days between two dates
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.145 seconds in which 0.084 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org