简体   繁体   中英

Convert SQL Server date to As400 date

I have a date in SQL Server in this format: 1/1/2013 14:15:16

I want to convert it to 2013-1-1-14.15.16.000000

I did this in C# by doing something like this

dateValue.toString("YYYY-MM-dd-hh.mm.ss.000000")

Is there a format conversion that I should use?

I would prefer to do it in c# code.

select Replace( Replace( Convert( VarChar(26), SysDateTime(), 121 ), ' ', '-' ), ':', '.' )

Perhaps you could simply SET DATEFORMAT on the SQL Server side. Nice and simple.

(Caveat: I'm a DB2 for i guy, not a SQL Server expert)

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