Difference between revisions of "DateTime compare"

From Catglobe Wiki
Jump to: navigation, search
Line 25: Line 25:
 
'''Example'''
 
'''Example'''
  
array a1 = DateTime_getByYMD(1985,12,24);
+
''array datetime1 = DateTime_getByYMD(1985,12,24);''
  
array a2 = getCurrentDateTime();
+
''array datetime2 = getCurrentDateTime();''
  
bool result = DateTime_compare(a1, a2);
+
''number result = DateTime_compare(datetime1, datetime2);''
 +
 
 +
''if (result == -1)''
 +
 
 +
''  print("Date time 1 < Date time 2");''
 +
 
 +
''else if (result == 0)''
 +
 
 +
''  print("Date time 1 = Date time 2");''
 +
 
 +
''else if (result == 1)''
 +
 
 +
''  print("Date time 1 > Date time 2");''
 +
 
 +
''//Date time 1 < Date time 2
  
 
'''Availability'''
 
'''Availability'''

Revision as of 05:42, 21 December 2011




DateTime_compare

Compare 2 datetimes

Syntax

DateTime_compare(date1, date1);

Arguments

  • date1, date2 are arrays which are datetimes to be compared

Return value

number in which:

  • - 1: DateTime_Comparison_Less
  • 0 : DateTime_Comparison_Equal
  • 1: DateTime_Comparison_Greater

Example

array datetime1 = DateTime_getByYMD(1985,12,24);

array datetime2 = getCurrentDateTime();

number result = DateTime_compare(datetime1, datetime2);

if (result == -1)

print("Date time 1 < Date time 2");

else if (result == 0)

print("Date time 1 = Date time 2");

else if (result == 1)

print("Date time 1 > Date time 2");

//Date time 1 < Date time 2

Availability

Version 5.7