Date and Time in PeopleCode

本文详细介绍了在PeopleCode中将日期字段置空的多种方法,包括使用SetDefault()函数和Value属性。同时,文章还提供了获取当前时间并转换为HHMMSS格式的技巧,以及在SQL查询中正确使用%DateOut获取日期变量的方法。

Setting a Date to Null in PeopleCode

To set a date to null in PeopleCode either use the SetDefault() function (deprecated) or the SetDefault field method

Using the function:

SetDefault(YOUR_RECORD.DT_FIELD);

Using the field method If you are in the current context:

YOUR_RECORD.DT_FIELD.SetDefault();

Using the field method if you are not in the current context using a field object:

Local Field &fldDateExample;/* Code to set your &fldDateExample object */&fldDateExample.SetDefault();

Not intuitive but it works.

Setting a Date to Null in PeopleCode (Part II - another way!)

There is also another way to set a date to null via PeopleCode! In some cases, using SetDefault() to blank out a field is not what we're after, as there may be a default for the field! The only other way (to my knowledge) is this:

RECNAME.DATE_FIELD.Value = "";

.Value is the KEY here. Not including .Value will throw Syntax errors in App Designer when you try to assign the date field to "" and save your program.

Getting the time in the format HHMMSS from the current time:

Getting time in the format HHMMSS from the current time:

Local &strCurrentTime;&strCurrentTime = Substring(Substitute(String(TimePart(%Datetime)), ".", ""), 1, 6);

This takes the time part of the current date time on the application server, replaces the dot (.) seperators with blanks, and returns only the first 6 characters (hhmmss) ignoring the millisecond part. This returns say a time of 11.52.00.000000 as 115200. I used this in an application to rename a file with a date & time stamp.

Use %DateOut to Get Dates from SQL into a Date Variable

If you are using a date that is returned from SQL and storing it into a date variable, make sure you wrap your date with %DateOut in your SQL, otherwise PeopleSoft will throw an invalid date error.

转载于:https://www.cnblogs.com/bryanchen/p/3385917.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值