Style: Datetime Fields

This topic accompanies the Styling Table Fields topic to provide reference detail on styling fields in tables for datetime data types.  Please review the Styling Table Fields topic for an introduction and step by step examples before proceeding with this topic.

Datetime Styles

The Style dialog provides an extensive selection of different date and time styles, which will automatically adapt to language-country choices specified in the Language setting.  Over 600 languages are supported by Manifold in Windows 10, with automatic use of correct language names for days of the week and months and automatic use of the correct cultural format for the country.

 

 

(default)

Short date + long time (default):   3/15/2021 19:30:00

d

Short date: 3/15/2021

D

Long date: Wednesday, March 15, 2021

f

Long date + short time:  Monday, March 15, 2021 19:30

F

Long date + long time:   Monday, March 15, 2021 19:30:00

g

Short date + short time:   3/15/2021 19:30

G

Short date + long time (default):   3/15/2021 19:30:00

m

Short month and day:   15 Mar

M

Long month and day:   15 March

r

RFC1123 (language ignored, always neutral):  Mon, 15 Mar 2021 19:30:00 GMT

s

Sortable (language ignored, always neutral):    2021-03-15T19:30:00

t

Short time:   19:30

T

Long time:   19:30:00

u

Universal sortable  (language ignored, always neutral):   2021-03-15 19:30:00Z

y

Year and month:   March 2021

 

The styles shown above are for the neutral  language choice.  Styles shown for a language are the most popular given that language and culture.  To get other variations, use a custom style.   For example, the neutral option provides styles with results like 15 March, but not 15 March 2021 or March 15, 2021.  To get those other alternatives, use a custom styles like dd MMMM yyyyy or MMMM dd, yyyyy.

Example

The table has two datetime fields, with the Datetime Copy field having copies of values in the Datetime field to allow quick comparison of display options.   Using the default option for the Datetime field and the D option with neutral choice of Language for the Datetime Copy field:

 

 

Using the f option (long date + short time) option for both fields, but using Arabic language as used in Qatar (ar-QA) for the Datetime field and German as used in Germany (de-DE) for the Datetime Copy field:

 

 

Some language formats do not use days of the week, or may use very different order than used in the neutral or English language settings.   The setting for Arabic in Qatar, for example, uses 12 hour clock time, with the local language equivalent of AM or PM used.

Datetime Custom Styles

The Custom tab in the Style dialog for datetime fields allows us to construct a custom pattern to specify the display style of datetime values.

 

 

Enter a style pattern in the Pattern box.   A preview of what the style pattern generates appears just below the Pattern box.   

 

A pattern can be any combination of patterns listed in the Custom tab list, together with any other characters desired.    

 

 

d

Day:   15

dd

Day:   15

ddd

Short week day:   Mon

dddd

Long week day:   Monday

g

Era:   A.D.

gg

Era:   A.D.

h

Hour on a 12-hour scale:   7

hh

Hour on a 12-hour scale, leading zero:   07

H

Hour on a 24-hour scale:   19

HH

Hour on a 24-hour scale:   19

m

Minute:   30

mm

Minute, leading zero:   30

M

Month as a number:    3

MM

Month as a number, leading zero:   03

MMM

Short month:   Mar

MMMM

Long month:   March

s

Second:   0

ss

Second, leading zero:    00

t

Short time marker:   P

tt

Long time marker:   PM

y

Short year:  21

yy

Short year, leading zero:  21

yyy

Long year:   2021

yyyy

Long year:   2021

yyyyy

Long year:   2021

 

Long year patterns accept up to five letters because some language/country combinations allow up to five digits in the year.

Building a Pattern

We can enter parts of a pattern by either keyboarding them in the Pattern box or by double-clicking a pattern in the Custom list to add it to the pattern.

 

If only a single character appears in the Pattern box that matches one of the styles in the Standard tab, that will generate that style from the Standard tab.  For example, the default example pattern of d matches the short date option, so the preview shows a short date style of 03/15/2021.   That allows us to quickly use a single-character style from the Standard list.

 

If more than one character appears in the Pattern box, then the resulting pattern is parsed based on the patterns listed in the Custom tab, together with any other characters that might be in the pattern.  Any character or any character sequence different from the above patterns, for example, / or :, is copied without any changes.

 

 

For example, the pattern d-MMM-yy h:mm results in the preview 15-Mar-21 7:30.   

 

 

Changing the pattern to d-MMM-yy H:mm results in the preview 15-Mar-21 19:30.   , since replacing the h pattern for hour on a 12-hour scale with H for hour on a 24-hour scale results in the 7 in the hour part of the time to be replaced with 19.

 

 

Changing the language to de-DE for German as spoken in Germany translates the various pattern results into German language, using Mrz as an abbreviation for März (March in German).

Example

The example table below has two datetime fields, with the Datetime Copy field having copies of values in the Datetime field to allow quick comparison of display options.   Using the default option for the Datetime with neutral choice of Language for both fields, and then specifying a Custom pattern for the Datetime Copy field:

 

Using a Pattern of d-MMM-yy h:mm tt

 

 

Results:

 

 

 

Using a Pattern of dddd, d MMMM, yyyy g

 

 

Results:

 

 

Using a Pattern of hh:mm:ss (dd.mm.yyyy)

 

 

Results:

 

 

Note that in all of the above, the datetime values are exactly the same.   The only thing that has changed is how they are displayed in tables, the info pane, and in labels.

 

See Also

Styling Table Fields

 

Style: Binary, Boolean, UUID Fields

 

Style: Geom, Tile Fields

 

Style: Numeric Fields

 

Style: Text Fields

 

Styling Choices in Tables