Beas works only with DateTime fields
instance datetime
if you want to define a datetime field, you must always use format ccyy/mm/dd
if you want to define with time, you must use ccyy/mm/dd hh:mm
if you want to save a datetime variable to database, you must use the format dbdate
Example
local datetime ld_today
ld_today=<today,yyyy/mm/dd>
sql=update myTable set myDateField=<ld_today,dbdate>
Note:
If you work with setvar, then use always format ccyy/mm/dd.
The conversion to another formats will work correctly only this way.
Convert string to date:
setvar=cdatum=<today,yyyy/mm/dd>
messagebox=<cdatum,date yyyymmdd> 23:30 => 20030201 23:30
The following standard formats are available:
Format |
Description |
---|---|
date |
language-depending display and print |
dbdate |
database-depending pass-on to the SELECT-command Do not use quotation marks select * from "ORDR" where "DocDate"=<today,dbdate> |
userdate |
Date format current user (regional settings) |
dayname |
Name of current day in the language from current user |
week |
Week number (from company calendar) |
yearweek |
Year + Week, example 2021/41 |
time |
Time in user format |
datetime |
Date + Time in current user format |
Example:
datetime ldt_date
ldt_date=<today,yyyy/mm/dd>
messagebox=<ldt_date,dayname>
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, upper-case abbreviation (AM or PM as appropriate)
am/pm Two-character, lower-case abbreviation (am or pm as appropriate)
A/P One-character, upper-case abbreviation (A or P as appropriate)
a/p One-character, lower-case abbreviation (a or p as appropriate)
[time] The keyword [Time] tells PowerBuilder to use the time format specified in the Microsoft Windows control panel.
Usage
24-hour format is the default. Times display in 24-hour format unless you specify AM/PM, am/pm, A/P, or a/p.
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/03 21:45
message=<timefield,hh:mm:ss AM/PM>: 08:00:00 PM
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
Colons, slashes, and spaces display as entered in the mask.
Format Displays
[red]m/d/yy 1/30/03 (color only in format fields)
d-mmm-yy 30-Jan-03
dd-mmmm 30-January
mmm-yy Jan-03
dddd, mmm d, yyyy Friday, Jan 30, 2003
Example for datetime
message=<timestampfield,MMMM d yyyy hh:mm:ss AM/PM>: January 1 2021 08:00:00 PM
message=<timestampfield,MMMM d, yyyy HH:mm:ss AM/PM>: December 31, 2021 20:00:00 PM
for convert date in sql-statements work with format-string dbdate!
select * from mytable where date_id between <fromdate,dbdate> and <todate,dbdate>
write datetime-field
set a datetime-field with format yyyy/mm/dd hh:mm
Example:
dw_1.item.fromdate.value=<today,yyyy/mm/dd> <now,time>