简体   繁体   中英

How to convert Delphi dates in SQL Server into DD.MM.YYYY

In my SQL Server database dates are stored in Delphi format (as integers). For example 43696 represents date 19.08.2019. I transform it into DD.MM.YYYY format using:

CONVERT(VARCHAR,CONVERT(DATETIME,delphidate-2),104)

(Actually here I have two conversions: first conversion of INTEGER into DATETIME format, then conversion of DATETIME into formatted VARCHAR).

Is there any easier (more convenient) means to do that?

您必须传递datedelphi作为datetime类型的参数查询,然后使用转换将时间设置为00:00:00

CONVERT(VARCHAR,CONVERT(DATETIME, :delphidate-2),104)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM