diff --git a/DateUtils.Test/DatePartTest.yxmd b/DateUtils.Test/DatePartTest.yxmd index 7dc9aa6..c96a7a6 100644 --- a/DateUtils.Test/DatePartTest.yxmd +++ b/DateUtils.Test/DatePartTest.yxmd @@ -288,12 +288,12 @@ Table=`Sheet1$` - + - diff --git a/DateUtils.xml b/DateUtils.xml index 050ba2e..6e0354b 100644 --- a/DateUtils.xml +++ b/DateUtils.xml @@ -247,8 +247,8 @@ DATEPART 2 DateTime - DATEPART(DateTime, Part) + DATEPART(interval, dt) Reproduces SQL Server's DatePart function. Support SQL servers standard parts as well as the numeric Alteryx date formatters. - Switch(LOWERCASE(P2),NULL(),"year",Year(P1),"yyyy",Year(P1),"yy",Year(P1),"%y",Year(P1),"cc",Century(P1),"c",Century(P1),"%c",Century(P1),"quarter",Quarter(P1),"qq",Quarter(P1),"q",Quarter(P1),"month",Month(P1),"mm",Month(P1),"m",Month(P1),"dayofyear",OrdinalDay(P1),"dy",OrdinalDay(P1),"y",OrdinalDay(P1),"%j",OrdinalDay(P1),"day",DAY(P1),"dd",DAY(P1),"d",DAY(P1),"%d",DAY(P1),"%e",DAY(P1),"hour",HOUR(P1),"hh",HOUR(P1),"h",HOUR(P1),"%h",HOUR(P1),"%k",HOUR(P1),"mi",MINUTE(P1),"n",MINUTE(P1),"ss",SECOND(P1),"s",SECOND(P1),"%s",SECOND(P1),"%m",IIF(CharToInt(Right(P2,1))=77, MINUTE(P1),MONTH(P1)),"weekday",WEEKDAY(P1),"dw",WEEKDAY(P1)) + Switch(LOWERCASE(P1),NULL(),"year",Year(P2),"yyyy",Year(P2),"yy",Year(P2),"%y",Year(P2),"century",Century(P2),"cc",Century(P2),"c",Century(P2),"%c",Century(P2),"quarter",Quarter(P2),"qq",Quarter(P2),"q",Quarter(P2),"month",Month(P2),"mm",Month(P2),"m",Month(P2),"dayofyear",OrdinalDay(P2),"dy",OrdinalDay(P2),"y",OrdinalDay(P2),"%j",OrdinalDay(P2),"day",DAY(P2),"dd",DAY(P2),"d",DAY(P2),"%d",DAY(P2),"%e",DAY(P2),"hour",HOUR(P2),"hh",HOUR(P2),"h",HOUR(P2),"%h",HOUR(P2),"%k",HOUR(P2),"mi",MINUTE(P2),"n",MINUTE(P2),"ss",SECOND(P2),"s",SECOND(P2),"%s",SECOND(P2),"%m",IIF(CharToInt(Right(P1,1))=77, MINUTE(P2),MONTH(P2)),"weekday",WEEKDAY(P2),"dw",WEEKDAY(P2)) diff --git a/MiscUtils.xml b/MiscUtils.xml index ffe3602..23b376d 100644 --- a/MiscUtils.xml +++ b/MiscUtils.xml @@ -50,7 +50,7 @@ Returns if a numeric value exists AlteryxAbacus.dll - VarTextExists + VarNumExists diff --git a/README.md b/README.md index c8da37c..8f7cce0 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Some additional functions for working with Dates and to a certain extent Times. - [WeekDay](https://github.com/jdunkerley/AlteryxFormulaAddOns/wiki/Date-and-Time-Functions-(DateUtils.xml)#weekday): Gets the day of the week [Sunday (0) through to Saturday (6)] - [Quarter](https://github.com/jdunkerley/AlteryxFormulaAddOns/wiki/Date-and-Time-Functions-(DateUtils.xml)#quarter): Gets the quarter of the date [1-4] - [OrdinalDay](https://github.com/jdunkerley/AlteryxFormulaAddOns/wiki/Date-and-Time-Functions-(DateUtils.xml)#ordinalday): Gets the day of the year [1-366] +- [DatePart](https://github.com/jdunkerley/AlteryxFormulaAddOns/wiki/Date-and-Time-Functions-(DateUtils.xml)#datepart): Replicates the SQL DatePart function, getting a specified part of the datetime input #### Time Part Functions (returns numbers) #### diff --git a/StringUtils.xml b/StringUtils.xml index 8c1cd02..b566182 100644 --- a/StringUtils.xml +++ b/StringUtils.xml @@ -109,4 +109,12 @@ FromRoman + + FINDSTRINGLAST + 2 + String + FINDSTRINGLAST(String, Target) + Searches for the occurrence of Target within String from end and returns the numeric position of it. + FINDSTRING(REVERSE(P1),REVERSE(P2)) +