Date and time manipulation functions

These functions work with the Horolog format (like $H).

See Useful string manipulation functions for use of these functions

CompareDate
Compares two date-time on the date member only CompareDate(dh1,dh2) s dh1=+dh1 s dh2=+dh2 q:dh1dh2 1 q 0
 * Arguments:
 * dh1: first datetime(X,Y) or date (X)
 * dh2: second datetime or date
 * Returns:-1 if dh1dh2

CompareDateTime
Compares two date-time //Compare deux date-heures sur la date et l'heure //Renvoie -1 si dh1dh2 CompareDateTime(dh1,dh2) //compare the dates s d1=+dh1, d2=+dh2 q:d1d2 1 //same dates, compare time s d1=$P(dh1,",",2), d2=$P(dh2,",",2) q:d1d2 1 q 0
 * Arguments:
 * dh1: first datetime(X,Y)
 * dh2: second datetime
 * Returns:-1 if dh1dh2

AgeInSeconds
Returns the time elapsed between two date-time in seconds AgeInSeconds(dh1,dh2) q $ZABS((+dh2-dh1*84600+(+$P(dh2,",",2)-$P(dh1,",",2)))
 * Arguments:
 * dh1: first datetime(X,Y)
 * dh2: second datetime
 * Returns:Number of seconds between dh1 and dh2

AgeInDays
Returns the time elapsed between two date-time in days AgeInDays(dh1,dh2) q:(dh1="")||(dh1="") 0 s res=$ZABS((+dh2-dh1*84600+(+$P(dh2,",",2)-$P(dh1,",",2))) 	q (res/84600+0.5)\1
 * Arguments:
 * dh1: first datetime(X,Y)
 * dh2: second datetime
 * Returns:Number of days between dh1 and dh2

AgeInYears
Returns the time elapsed between two date-time in years AgeInYears(dh1,dh2) q:(dh1="")||(dh1="") 0 q $NUM($ZABS(+dh1-dh2)/365.25,2)
 * Arguments:
 * dh1: first datetime(X,Y) or date (X)
 * dh2: second datetime or date
 * Returns:Number of years between dh1 and dh2

DateAdd
Add two date-time. Used to add a timelapse expressed in Horolog format to a datetime DateAdd(dh1,dh2) new h	s h=+$P(dh1,",",2)+$P(dh2,",",2) q:h>86399 +dh1+dh2+1_","_(h-86400) q +dh1+dh2_","_h
 * Arguments:
 * dh1: first datetime(X,Y) or date (X)
 * dh2: second datetime(X,Y) or date(X) or time (0,Y)
 * Returns:sum of dh1 and dh2

function
description
 * Arguments:
 * arg:
 * Returns: