diff --git a/src/main/java/com/samskivert/depot/DateFuncs.java b/src/main/java/com/samskivert/depot/DateFuncs.java index b942673..1862275 100644 --- a/src/main/java/com/samskivert/depot/DateFuncs.java +++ b/src/main/java/com/samskivert/depot/DateFuncs.java @@ -43,7 +43,15 @@ public class DateFuncs /** * Creates an expression to extract the day-of-week from the the supplied timestamp expression. */ - public static FluentExp dayOfWeek (SQLExpression exp) + public static FluentExp dayOfWeek (SQLExpression exp) + { + return new DatePart(exp, DatePart.Part.DAY_OF_WEEK); + } + + /** + * Creates an expression to extract the day-of-week from the the supplied date expression. + */ + public static FluentExp dayOfWeekFromDate (SQLExpression exp) { return new DatePart(exp, DatePart.Part.DAY_OF_WEEK); } @@ -51,7 +59,15 @@ public class DateFuncs /** * Creates an expression to extract the day-of-month from the the supplied timestamp expression. */ - public static FluentExp dayOfMonth (SQLExpression exp) + public static FluentExp dayOfMonth (SQLExpression exp) + { + return new DatePart(exp, DatePart.Part.DAY_OF_MONTH); + } + + /** + * Creates an expression to extract the day-of-month from the the supplied date expression. + */ + public static FluentExp dayOfMonthFromDate (SQLExpression exp) { return new DatePart(exp, DatePart.Part.DAY_OF_MONTH); } @@ -59,7 +75,15 @@ public class DateFuncs /** * Creates an expression to extract the day-of-year from the the supplied timestamp expression. */ - public static FluentExp dayOfYear (SQLExpression exp) + public static FluentExp dayOfYear (SQLExpression exp) + { + return new DatePart(exp, DatePart.Part.DAY_OF_YEAR); + } + + /** + * Creates an expression to extract the day-of-year from the the supplied data expression. + */ + public static FluentExp dayOfYearFromDate (SQLExpression exp) { return new DatePart(exp, DatePart.Part.DAY_OF_YEAR); } @@ -67,7 +91,7 @@ public class DateFuncs /** * Creates an expression to extract the hour of the the supplied timestamp expression. */ - public static FluentExp hour (SQLExpression exp) + public static FluentExp hour (SQLExpression exp) { return new DatePart(exp, DatePart.Part.HOUR); } @@ -75,7 +99,7 @@ public class DateFuncs /** * Creates an expression to extract the minute of the the supplied timestamp expression. */ - public static FluentExp minute (SQLExpression exp) + public static FluentExp minute (SQLExpression exp) { return new DatePart(exp, DatePart.Part.MINUTE); } @@ -83,7 +107,7 @@ public class DateFuncs /** * Creates an expression to extract the second of the the supplied timestamp expression. */ - public static FluentExp second (SQLExpression exp) + public static FluentExp second (SQLExpression exp) { return new DatePart(exp, DatePart.Part.SECOND); } @@ -94,7 +118,7 @@ public class DateFuncs /** * Creates an expression to extract the week of the the supplied timestamp expression. */ - public static FluentExp week (SQLExpression exp) + public static FluentExp week (SQLExpression exp) { return new DatePart(exp, DatePart.Part.WEEK); } @@ -102,7 +126,7 @@ public class DateFuncs /** * Creates an expression to extract the month of the the supplied timestamp expression. */ - public static FluentExp month (SQLExpression exp) + public static FluentExp month (SQLExpression exp) { return new DatePart(exp, DatePart.Part.MONTH); } @@ -110,7 +134,7 @@ public class DateFuncs /** * Creates an expression to extract the year of the the supplied timestamp expression. */ - public static FluentExp year (SQLExpression exp) + public static FluentExp year (SQLExpression exp) { return new DatePart(exp, DatePart.Part.YEAR); } @@ -119,7 +143,7 @@ public class DateFuncs * Creates an expression to extract the epoch (aka unix timestamp, aka seconds passed since * 1970-01-01) of the the supplied timestamp expression. */ - public static FluentExp epoch (SQLExpression exp) + public static FluentExp epoch (SQLExpression exp) { return new DatePart(exp, DatePart.Part.EPOCH); } diff --git a/src/main/java/com/samskivert/depot/impl/expression/DateFun.java b/src/main/java/com/samskivert/depot/impl/expression/DateFun.java index 29e641f..f2ea6a8 100644 --- a/src/main/java/com/samskivert/depot/impl/expression/DateFun.java +++ b/src/main/java/com/samskivert/depot/impl/expression/DateFun.java @@ -30,7 +30,7 @@ import com.samskivert.depot.impl.expression.Function.OneArgFun; public abstract class DateFun { - public static class DatePart extends OneArgFun { + public static class DatePart extends OneArgFun { public enum Part { DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_YEAR, HOUR, MINUTE, MONTH, SECOND, WEEK, YEAR, EPOCH