Clone wiki

grails-datatables / DateFormatting

Date Formatting

The GrailsDataTables plugin provides three types of date formatting that relate to the three date dataTypes: date, dateTime, and time. You can specify which format you would like your column to be presented in by using the dataType column option.

The default formats are as follows:

dataType Default Format Default SQL Server Format
date MM/dd/yyyy MM/dd/yyyy
dateTime MM/dd/yyyy HH:mm:ss MMM dd yyyy HH:mma
time HH:mm:ss HH:mm:ss

SQL Server uses a different dateTime format because the function it provides for converting dates to strings does not support the default format.

You can change any of these formats to be whatever format you like by setting the respective configuration option:

If your date column is searchable and you are using server side processing, then you will also need to set the respective database date format configuration option:

This is because the service that performs the search needs to know how to convert the date to the correct format in the database in order to construct the search query.

If you are using SQL Server, then instead of a pattern, the database date formats will be a number that references a pattern. In this case, you may also need to set the respective date format length configuration option:

Refer to w3schools for a description of how SQL Server converts dates.

See Also

Database Compatibility

Back to Home.