PeopleSoft 查询管理器表达式

PeopleSoft Query Manager Expression

使用 Microsoft SQL 服务器,我正在尝试将 A.CHECK_DT 格式化为 mmddyyyy - 带有前导零,因此今年的 1 月 11 日看起来像:01112019。 麻烦的是我尝试的一切都不对。我最接近改变格式的是:

CONCAT(MONTH((CONVERT(CHAR(10),A.CHECK_DT,101))),DAY((CONVERT(CHAR(10),A.CHECK_DT,101))),YEAR((CONVERT(CHAR(10),A.CHECK_DT,101))))

但这会将日期转换为 1182019,没有前导零。有人有什么想法吗?

[edit] 下面的评论适用于 Oracle 数据库,但事实证明这个问题是针对 Microsoft SQL 服务器的。我将留下答案,以防它对通过搜索找到此问题的其他人有用。

Assuming you are on oracle, try using an additional parameter on the TO_CHAR function to tell it how you want to format the output.

You can format the date using TO_CHAR. the syntax is something like TO_CHAR(YOURDATE,YOURFORMAT). And for your specific example, it would be TO_CHAR(A.CHECK_DT,'MMDDYYYY')

Here is a web page that shows this SQL as a working query:

Here are some good resources I found by searching for: Oracle TO_CHAR:

And of course, there is always Oracle documentation (although it tends to have fewer examples):

我想通了:

此脚本将为您提供格式为 MMDDYYYY

替换(CONVERT(VARCHAR(10), CAST(A.CHECK_DT AS DATE), 101),'/','')

(表达式类型 = 字符,长度 10)