A date time item can use as date, time or date time. For Date time you can define the date and time format in one sequence
Date display formats
Date display formats can have two sections. The first is required and contains the format for dates; the second is optional and specifies how to represent NULLs:
date-format;null-format
Special characters
The following table shows characters that have special meaning in date display formats.
Character |
Meaning |
Example |
|---|---|---|
d |
Day number with no leading zero |
9 |
dd |
Day number with leading zero if appropriate |
09 |
ddd |
Day name abbreviation |
Mon |
dddd |
Day name |
Monday |
m |
Month number with no leading zero |
6 |
mm |
Month number with leading zero if appropriate |
06 |
mmm |
Month name abbreviation |
Jun |
mmmm |
Month name |
June |
yy |
Two-digit year |
97 |
yyyy |
Four-digit year |
1997 |
Note: only english supported. For display Names in correct language see object Date
Colons, slashes, and spaces display as entered in the mask.
About 2-digit years
If users specify a 2-digit year in a DataWindow object, PowerBuilder assumes the date is the 20th century if the year is greater than or equal to 50. If the year is less than 50, PowerBuilder assumes the 21st century. For example:
1/1/85 is interpreted as January 1, 1985.
1/1/40 is interpreted as January 1, 2040.
Examples
The following table shows how the date Friday, January 30, 1998, displays when different format masks are applied.
Format |
Displays |
|---|---|
[red]m/d/yy |
1/30/98 in red |
d-mmm-yy |
30-Jan-98 |
dd-mmmm |
30-January |
mmm-yy |
Jan-98 |
dddd, mmm d, yyyy |
Friday, Jan 30, 1998 |
Time display formats
Time display formats can have two sections. The first is required and contains the format for times; the second is optional and specifies how to represent NULLs:
time-format;null-format
Special characters
The following table shows characters that have special meaning in time display formats.
Character |
Meaning |
|---|---|
h |
Hour with no leading zero (for example, 1) |
hh |
Hour with leading zero if appropriate (for example, 01) |
m |
Minute with no leading zero (must follow h or hh) |
mm |
Minute with leading zero if appropriate (must follow h or hh) |
s |
Second with no leading zero (must follow m or mm) |
ss |
Second with leading zero (must follow m or mm) |
ffffff |
Microseconds with no leading zeros. You can enter one to six f's; each f represents a fraction of a second (must follow s or ss) |
AM/PM |
Two-character, uppercase abbreviation (AM or PM as appropriate) |
am/pm |
Two-character, lowercase abbreviation (am or pm as appropriate) |
A/P |
One-character, uppercase abbreviation (A or P as appropriate) |
a/p |
One-character, lowercase abbreviation (a or p as appropriate) |
Colons, slashes, and spaces display as entered in the mask.
24-hour format is the default
Times display in 24-hour format unless you specify AM/PM, am/pm, A/P, or a/p.
Examples
The following table shows how the time 9:45:33:234567 PM displays when different format masks are applied.
Format |
Displays |
|---|---|
h:mm AM/PM |
9:45 PM |
hh:mm A/P |
09:45 P |
h:mm:ss am/pm |
9:45:33 pm |
h:mm |
21:45 |
h:mm:ss |
21:45:33 |
h:mm:ss:f |
21:45:33:2 |
h:mm:ss:fff |
21:45:33:234 |
h:mm:ss:ffffff |
21:45:33:234567 |
m/d/yy h:mm |
1/30/98 21:45 |
Date Time
For Date time compinate date and time field
Examples:
Format |
Displays |
|---|---|
yyyy/mm/dd h:mm AM/PM |
2020/12/07 9:45 PM |