diff --git a/resources/function_help/$now-en_US b/resources/function_help/$now-en_US new file mode 100644 index 00000000000..4e75b060298 --- /dev/null +++ b/resources/function_help/$now-en_US @@ -0,0 +1,12 @@ +

$now function

+Returns the current data and time + +

Syntax

+
$now
+ +

Arguments

+None +

Example

+ +
$now -> 2012-07-22T13:24:57
+ diff --git a/resources/function_help/Date and Time-en_US b/resources/function_help/Date and Time-en_US new file mode 100644 index 00000000000..da11bcb5364 --- /dev/null +++ b/resources/function_help/Date and Time-en_US @@ -0,0 +1,2 @@ +

Date and Time Group

+This group contains functions for handling date and time data. diff --git a/resources/function_help/age-en_US b/resources/function_help/age-en_US new file mode 100644 index 00000000000..803f1d1b72a --- /dev/null +++ b/resources/function_help/age-en_US @@ -0,0 +1,32 @@ +

age() function

+Returns the difference between two dates. +

+The difference is returned as a Interval +and needs to be used with one of the following functions +in order to extract useful information: +

+ - year
+ - month
+ - week
+ - day
+ - hour
+ - minute
+ - second
+
+

Syntax

+age(string,string)
+age(datetime,datetime)
+age(string,datetime)
+age(datetime,string)
+ +

Arguments

+string - is string. A sting in date format. +
+datetime - is date or datetime. A date or datetime type. + +

Example

+ +age('2012-05-12','2012-05-2') -> Interval
+use day to extract numbder of days
+day(age('2012-05-12','2012-05-2')) -> 10
+ diff --git a/resources/function_help/day-en_US b/resources/function_help/day-en_US new file mode 100644 index 00000000000..4571df82ec4 --- /dev/null +++ b/resources/function_help/day-en_US @@ -0,0 +1,19 @@ +

day() function

+Extract the day from a date, or the number of days +from a Interval + +

Syntax

+day(date)
+day(Interval)
+ +

Arguments

+date - is date or datetime. The date to extract the day from. +
+Interval - is Interval. The Interval to return the number of days from. + +

Example

+ +day('2012-05-12') -> 12
+day(tointerval('3 days')) -> 3
+day(age('2012-01-01','2010-01-01')) -> 730
+ diff --git a/resources/function_help/hour-en_US b/resources/function_help/hour-en_US new file mode 100644 index 00000000000..565856e8f9b --- /dev/null +++ b/resources/function_help/hour-en_US @@ -0,0 +1,20 @@ +

hour() function

+Extract the hour from a datetime or time, or the number of hours +from a Interval + +

Syntax

+hour(datetime)
+hour(Interval)
+ +

Arguments

+date - is datetime or time. The date to extract the hour from. +
+Interval - is Interval. The Interval to return the number of hours from. + +

Example

+ +hour('2012-07-22T13:24:57') -> 13
+hour(tointerval('3 hours')) -> 3
+hour(age('2012-07-22T13:00:00','2012-07-22T10:00:00')) -> 3
+hour(age('2012-01-01','2010-01-01')) -> 17520
+ diff --git a/resources/function_help/minute-en_US b/resources/function_help/minute-en_US new file mode 100644 index 00000000000..7eccfb64d57 --- /dev/null +++ b/resources/function_help/minute-en_US @@ -0,0 +1,20 @@ +

minute() function

+Extract the minute from a datetime or time, or the number of minutes +from a Interval + +

Syntax

+minute(datetime)
+minute(Interval)
+ +

Arguments

+date - is datetime or time. The date to extract the minute from. +
+Interval - is Interval. The Interval to return the number of minutes from. + +

Example

+ +minute('2012-07-22T13:24:57') -> 24
+minute(tointerval('3 minutes')) -> 3
+minute(age('2012-07-22T00:20:00','2012-07-22T00:00:00')) -> 20
+minute(age('2012-01-01','2010-01-01')) -> 1051200
+ diff --git a/resources/function_help/month-en_US b/resources/function_help/month-en_US new file mode 100644 index 00000000000..dd8aacd079b --- /dev/null +++ b/resources/function_help/month-en_US @@ -0,0 +1,19 @@ +

month() function

+Extract the month part from a date, or the number of months +from a Interval + +

Syntax

+month(date)
+month(Interval)
+ +

Arguments

+date - is date or datetime. The date to extract the month from. +
+Interval - is Interval. The Interval to return the number of months from. + +

Example

+ +month('2012-05-12') -> 05
+month(tointerval('3 months')) -> 3
+month(age('2012-01-01','2010-01-01')) -> 4.033...
+ diff --git a/resources/function_help/second-en_US b/resources/function_help/second-en_US new file mode 100644 index 00000000000..c8e2beef3b6 --- /dev/null +++ b/resources/function_help/second-en_US @@ -0,0 +1,20 @@ +

second() function

+Extract the seconds from a datetime or time, or the number of seconds +from a Interval + +

Syntax

+second(datetime)
+second(Interval)
+ +

Arguments

+date - is datetime or time. The date to extract the second from. +
+Interval - is Interval. The Interval to return the number of seconds from. + +

Example

+ +second('2012-07-22T13:24:57') -> 57
+second(tointerval('3 seconds')) -> 3
+second(age('2012-07-22T00:20:00','2012-07-22T00:00:00')) -> 1200
+second(age('2012-01-01','2010-01-01')) -> 63072000
+ diff --git a/resources/function_help/week-en_US b/resources/function_help/week-en_US new file mode 100644 index 00000000000..5f18fbb9ec7 --- /dev/null +++ b/resources/function_help/week-en_US @@ -0,0 +1,19 @@ +

week() function

+Extract the week number from a date, or the number of weeks +from a Interval + +

Syntax

+week(date)
+week(Interval)
+ +

Arguments

+date - is date or datetime. The date to extract the week from. +
+Interval - is Interval. The Interval to return the number of weeks from. + +

Example

+ +week('2012-05-12') -> 19
+week(tointerval('3 weeks')) -> 3
+week(age('2012-01-01','2010-01-01')) -> 104.285...
+ diff --git a/resources/function_help/year-en_US b/resources/function_help/year-en_US new file mode 100644 index 00000000000..bf27f6a135b --- /dev/null +++ b/resources/function_help/year-en_US @@ -0,0 +1,19 @@ +

year() function

+Extract the year part from a date, or the number of years +from a Interval + +

Syntax

+year(date)
+year(Interval)
+ +

Arguments

+date - is date or datetime. The date to extract the year from. +
+Interval - is Interval. The Interval to return the number of years from. + +

Example

+ +year('2012-05-12') -> 2012
+year(tointerval('3 Years')) -> 3
+year(age('2012-01-01','2010-01-01')) -> 1.9986..
+ diff --git a/src/core/qgsexpression.cpp b/src/core/qgsexpression.cpp index 130fda12d50..f60e346c554 100644 --- a/src/core/qgsexpression.cpp +++ b/src/core/qgsexpression.cpp @@ -756,16 +756,16 @@ const QList &QgsExpression::BuiltinFunctions() << FunctionDef( "totime", 1, fcnToTime, QObject::tr( "Conversions" ) ) << FunctionDef( "tointerval", 1, fcnToInterval, QObject::tr( "Conversions" ) ) << FunctionDef( "coalesce", -1, fcnCoalesce, QObject::tr( "Conversions" ) ) - // date/time - << FunctionDef( "$now", 0, fcnNow, QObject::tr( "Date/Time" ) ) - << FunctionDef( "age", 2, fcnAge, QObject::tr( "Date/Time" ) ) - << FunctionDef( "year", 1, fcnYear, QObject::tr( "Date/Time" ) ) - << FunctionDef( "month", 1, fcnMonth, QObject::tr( "Date/Time" ) ) - << FunctionDef( "week", 1, fcnWeek, QObject::tr( "Date/Time" ) ) - << FunctionDef( "day", 1, fcnDay, QObject::tr( "Date/Time" ) ) - << FunctionDef( "hour", 1, fcnHour, QObject::tr( "Date/Time" ) ) - << FunctionDef( "minute", 1, fcnMinute, QObject::tr( "Date/Time" ) ) - << FunctionDef( "second", 1, fcnSeconds, QObject::tr( "Date/Time" ) ) + // Date and Time + << FunctionDef( "$now", 0, fcnNow, QObject::tr( "Date and Time" ) ) + << FunctionDef( "age", 2, fcnAge, QObject::tr( "Date and Time" ) ) + << FunctionDef( "year", 1, fcnYear, QObject::tr( "Date and Time" ) ) + << FunctionDef( "month", 1, fcnMonth, QObject::tr( "Date and Time" ) ) + << FunctionDef( "week", 1, fcnWeek, QObject::tr( "Date and Time" ) ) + << FunctionDef( "day", 1, fcnDay, QObject::tr( "Date and Time" ) ) + << FunctionDef( "hour", 1, fcnHour, QObject::tr( "Date and Time" ) ) + << FunctionDef( "minute", 1, fcnMinute, QObject::tr( "Date and Time" ) ) + << FunctionDef( "second", 1, fcnSeconds, QObject::tr( "Date and Time" ) ) // string manipulation << FunctionDef( "lower", 1, fcnLower, QObject::tr( "String" ) ) << FunctionDef( "upper", 1, fcnUpper, QObject::tr( "String" ) )