Arcadian
Arcadian

Reputation: 4350

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.

Upvotes: 0

Views: 1230

Answers (2)

WarrenT
WarrenT

Reputation: 4532

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)

Upvotes: 1

HABO
HABO

Reputation: 15816

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

Upvotes: 1

Related Questions