SQL DATE_FORMAT in Alternative in Jooq
2018-03-01 18:36
169 查看
I’m using 3.5 jooq version
I know that jooq don’t support DATE_FORMAT function but what are the alternatives
This is the query that i want to create with JOOQ
Whenever you need a vendor-specific SQL feature that is not supported by jOOQ out of the box, the plain SQL API will be your friend. Write a utility as such:
You can then use it like any other jOOQ-provided function:
转载自http://w3cgeek.com/sql-date_format-in-alternative-in-jooq.html
I know that jooq don’t support DATE_FORMAT function but what are the alternatives
This is the query that i want to create with JOOQ
SELECT DATE_FORMAT(`date_create`, '%d/%m/%Y') AS date_create FROM users GROUP BY DATE_FORMAT(`date_create`, '%d/%m/%Y')
Whenever you need a vendor-specific SQL feature that is not supported by jOOQ out of the box, the plain SQL API will be your friend. Write a utility as such:
public static Field<String> dateFormat(Field<Date> field, String format) { return DSL.field("date_format({0}, {1})", SQLDataType.VARCHAR, field, DSL.inline(format)); }
You can then use it like any other jOOQ-provided function:
DSL.using(configuration) .select(dateFormat(USERS.DATE_CREATE, "%d/%m/%Y").as("date_create")) .from(USERS) .groupBy(dateFormat(USERS.DATE_CREATE, "%d/%m/%Y")) .fetch();
转载自http://w3cgeek.com/sql-date_format-in-alternative-in-jooq.html
相关文章推荐
- How to format datetime & date in Sql Server 2005
- SQLServer The datediff function resulted in an overflow
- T-sql date/time format samples
- Set Date diff format in Crystal Report Functions
- Date Time Format in ruby
- mysql数据库sql语句通过DATE_FORMAT格式化日期
- SQL Date Time format
- mysql数据库sql语句通过DATE_FORMAT格式化日期
- A guide to Java SimpleDateFormat in examples
- Date Formatting in Reporting Services - list of format codes
- sql SET DATEFORMAT对日期处理的影响
- How to use the date format that has been setup as default in Settings?
- mysql数据库sql语句通过DATE_FORMAT格式化日期
- How to format date for display or to use in a shell script
- Unity64 AStarPath 寻路失效 Bug解决 IOS64 IL2CPP - Bad date/time format in the zip file
- A guide to Java SimpleDateFormat in examples
- Datediff in Sql
- sqlserver date format
- sql date format
- Get XML tree format based on the tree data in SQL server table