å¦ï¼ç»å®çå¹´ææ ¼å¼ä¸º20157ï¼ä»£è¡¨2015å¹´7æã
åææ第ä¸å¤©ï¼
SELECT CAST((LEFT('20157',4)+'-'+SUBSTRING('20157',5,LEN('20157'))+'-'+'01') AS DATETIME)
ç»æï¼
如果是Oracle,可以这样写:
select to_date(to_char(sysdate,'yyyy-mm')||'-01', 'yyyy-mm-dd') from dual;sqlserver可以这样:
select cast(convert(varchar(8),getdate(),23)+'01' as datetime);本回答被提问者和网友采纳