[英]Sql change the result length or time format
My database is Oracle, and I use navicat to query data. 我的数据库是Oracle,我使用navicat查询数据。
My code is below: 我的代码如下:
select
jzmktr.VPRONAME as jzmktrvproname,
jzbid.vproname as jzbidvproname,
jzbid.vprolocus as jzbidvprolocus,
jzcur.vname as jzcurvname,
doc.name as docname,
zspm.def2 as zspmdef2,
oa.name as oaname,
zspm.def6 as zspmdef6,
zspm.def4 as zspmdef4,
zpus.def3 as zpusdef3,
jzbidt.dstartdate as jzbidtdstartdate,
jzbidt.dcompletedate as jzbidtdconpletedate,
zspm.def4 as zspmdef4,
jzcur.PK_GROUP
from JZMKT_REGISTER jzmktr
left join JZCU_REGISTER jzcur
on jzcur.PK_REGISTER = jzmktr.pk_customer
left join JZBID_VENDSTART jzbid
on jzmktr.PK_MKTREGISTER = jzbid.PK_MKTREGISTER
left join jzbid_hitbidlog hit
on hit.pk_vendstart = jzbid.pk_vendstart
left join ZSPM_MAK_EXPLANATION zspm
on zspm.def16 = hit.pk_hitbidlog
left join zspm_pub_uf_singlehead_h zpus
on zpus.def1 = jzmktr.PK_MKTREGISTER
left join JZBID_TENDERCHK jzbidt
on jzbidt.pk_vendstart = jzbid.pk_vendstart
left join bd_defdoc doc
on doc.pk_defdoc = jzbid.pk_operatetype
left join org_adminorg oa
on oa.pk_adminorg = zspm.def5
where jzmktr.dr='0' and jzmktr.FSTATUSFLAG='1'
You can see the snapshot, this is the sql
execute result, the time format of jzbidtdstartdate
and jzbidtdconpletedate
is yyyy-MM-dd HH:mm:ss
: 您可以看到快照,这是sql
执行结果, jzbidtdstartdate
和jzbidtdconpletedate
的时间格式为yyyy-MM-dd HH:mm:ss
:
How can I set the time format to yyyy-MM-dd
? 如何将时间格式设置为yyyy-MM-dd
?
EDIT 编辑
If I change the jzbidtdstartdate
to : 如果我将jzbidtdstartdate
更改为:
to_char(jzbidt.dstartdate, 'yyyy-MM-dd') as jzbidtdstartdate,
I will get this error: 我会收到此错误:
on doc.pk_defdoc = jzbid.pk_operatetype
left join org_adminorg oa
on oa.pk_adminorg = zspm.def5
where jzmktr.dr='0' and jzmktr.FSTATUSFLAG='1'
--and jzmktr.pk_org in (parameter('param3'))
-- and substr(jzmktr.dbilldate,1,10)>=parameter('param1')
-- and substr(jzmktr.dbilldate,1,10)<=parameter('param2')
[Err] ORA-01722: invalid number
UPDATE UPDATE
I search the jzbidt.dstartdate
in the database, it is CHAR
type. 我在数据库中搜索jzbidt.dstartdate
,它是CHAR
类型。
In your SQL select clause, change the column from jzbidt.dstartdate
to to_char(jzbidt.dstartdate, 'YYYY-MM-DD')
to get the date in your required format, assuming it is of a date
type. 在您的SQL select子句中,将列从jzbidt.dstartdate
更改为to_char(jzbidt.dstartdate, 'YYYY-MM-DD')
以获取所需格式的日期(假定它是date
类型)。
Since it is of char
type, you only need to do a substring, so substr(jzbidt.dstartdate, 0,10)
will work fine. 由于它是char
类型的,因此只需要执行一个子字符串,所以substr(jzbidt.dstartdate, 0,10)
可以正常工作。
如果jzbidt.dstartdate
是CHAR
,则应将char
转换为date
,然后格式化日期:
to_char(to_date(jzbidt.dstartdate, 'yyyy-MM-dd hh24:mi:ss'), 'yyyy-MM-dd'),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.