Custom Date and Time Format Strings

When you have a date or time as your data source, you can format it according to the locale of your language and geographical region. If none of the pre-defined formats work for you, BarTender lets you define a custom format using format strings. This custom format option is available on the Data Type tab of the Data Sources property page.

ClosedTo define a custom date or time format

  1. Double-click the desired object to open the Object Properties dialog. Alternatively, select Properties from the object's context menu.

  2. Click the data source containing the date or time to open the Data Sources property page.

  3. Click the Data Type tab.

  4. From the Type dropdown list, select Date or Time.

  5. From the Locale dropdown list, select the desired locale.

  6. In the Format list, select <Custom>.

  7. In the Pattern field, enter the desired date or time strings (described below). Spaces will be treated as literal characters. You can also separate date fields with a forward slash (/) and time fields with a colon (:). The Sample field displays a preview of how your date or time will appear.

For example:

The following format strings are available when defining a custom format for a date or time. Some of the following strings are not available for all locales.

ClosedDate-Specific Strings

Format Specifier

Description

Sample, given the date January 2, 2004

/

The date separator, based on the selected locale

 

d

The day of the month, from 1 through 31

2

dd

The day of the month, from 01 through 31

02

ddd

The abbreviated name of the day of the week

Fri

dddd

The full name of the day of the week

Friday

M

The month, from 1 through 12

1

MM

The month, from 01 through 12

01

MMM

The abbreviated name of the month

Jan

MMMM

The full name of the month

January

y

The year, from 0 to 99

4

yy

The year, from 00 to 99

04

yyy

The year, with a minimum of three digits

2004

yyyy

The year, as a four-digit number

2004

yyyyy

The year, as a five-digit number

02004

Y

The last digit of the year, from 0 to 9

4

YY

The last two digits of the year, from 00 to 99

04

YYY

The last three digits of the year, from 000 to 999

004

j

Julian date, from 1 to 366

2

jjj

Julian date, from 001 to 366

002

g

Period or era (B.C./A.D.)

A.D.

@d

Short date pattern

1/2/2004

@D

Long date pattern

Friday, January 02, 2004

@f

Full date and time pattern, with short time

Friday, January 02, 2004 12:00 AM

@F

Full date and time pattern, with long time

Friday, January 02, 2004 12:00:00 AM

@g

General date and time pattern, with short time

1/2/2004 12:00 AM

@G

General date and time pattern, with long time

1/2/2004 12:00:00 AM

@m

Month and day pattern

January 02

@y

Month and year pattern

January, 2004

@r

RFC1123 pattern

Fri, 02 Jan 2004 18:54:03 GMT

ClosedTime-Specific Strings

Format Specifier

Description

Sample, given the time 6:54:03 PM

:

The time separator, based on the selected locale

 

h

The hour, using a 12-hour clock from 1 to 12

6

hh

The hour, using a 12-hour clock from 01 to 12

06

H

The hour, using a 24-hour clock from 0 to 23

18

HH

The hour, using a 24-hour clock from 00 to 23

18

m

The minute, from 0 to 59

54

mm

The minute, from 00 to 59

54

s

The second, from 0 to 59

3

ss

The second, from 00 to 59

03

f

Tenths of a second

 

ff

Hundredths of a second

 

fff

Thousandths of a second; the millisecond

 

ffff

Ten thousandths of a second

 

fffff

Hundred thousandths of a second

 

ffffff

Millionths of a second; the microsecond

 

fffffff

Ten millionths of a second

 

F

Tenths of a second, with no trailing zeros

 

FF

Hundredths of a second, with no trailing zeros

 

FFF

Thousandths of a second, with no trailing zeros; the millisecond

 

FFFF

Ten thousandths of a second, with no trailing zeros

 

FFFFF

Hundred thousandths of a second, with no trailing zeros

 

FFFFFF

Millionths of a second, with no trailing zeros; the microsecond

 

FFFFFFF

Ten millionths of a second, with no trailing zeros

 

t

The first character of the AM/PM designator

P

tt

The AM/PM designator

PM

@t

Short time pattern

6:54 PM

@T

Long time pattern

6:54:03 PM

@f

Full date and time pattern, with short time

Friday, January 02, 2004 6:54 PM

@F

Full date and time pattern, with long time

Friday, January 02, 2004 6:54:03 PM

@g

General date and time pattern, with short time

1/2/2004 6:54 PM

@G

General date and time pattern, with long time

1/2/2004 6:54:03 PM

@r

RFC1123 pattern

Fri, 02 Jan 2004 18:54:03 GMT

ClosedOther Available Strings

Format Specifier

Description

Sample, given the date 1/2/2004 and the time 6:54:03 PM

'literal'

Literal string delimiter

 

\

The escape character. When the escape character is used, BarTender interprets the character immediately following the escape character as a literal character.

 

K

The time zone; returns Z for UTC or an empty value for local time.

Z

z

The number of hours offset from UTC, with no leading zeros

-8

zz

The number of hours offset from UTC, with a leading zero for a single-digit number

-08

zzz

The hours and minutes offset from UTC

-08:00

w

Weekday number, from 0 to 6 (where 0 = Sunday)

5

u

ISO 8601 weekday number, from 1 to 7 (where 1 = Monday)

5

U

Week number, from 0 through 53 (where Sunday is the first day of the week)

0

UU

Week number, from 00 through 53 (where Sunday is the first day of the week)

00

W

Week number, from 0 to 53 (where Monday is the first day of the week)

0

WW

Week number, from 00 to 53 (where Monday is the first day of the week)

00

WWW

Week number, from 1 to 54 (where Monday is the first day of the week)

1

WWWW

Week number, from 01 to 54 (where Monday is the first day of the week)

01

vvvv

ISO 8601 week numbering year

2004

VV

ISO 8601 week number, from 01 to 53

01