I have two columns in SQL Server. I have a SQL bulk insert and it stores date in following format inside the database:
The first column type is
DATETIME
- it stores dates in this format:2018-07-02 00:00:00.000
The second column type is
DATE
and it stores this format:2018-07-02
The below part is with out using bulk insert.
When I insert new date its format is changing. I have following code in my C# for first column and second column
DateTime.ParseExact(txtODR.Text, "dd/MM/yyyy", null);
DateTime.ParseExact(txtWorkCompDt.Text, "dd/MM/yyyy", null);
When I look in SQL Server, it stores in this way "2018-02-07 00:00:00.000" and "2018-02-07"
Why it doesn't store in required format when I try to insert/update from C# (2018-07-02 00:00:00.000 & 2018-07-02
). What is wrong here? Please help me
SQL Code
DECLARE @P_ORDER_RECIVED_DATE NVARCHAR(100) = '2018/15/02'
UPDATE [dbo].[T_INSTALATION]
SET [Order_Recieved_Date] = CONVERT(VARCHAR,@P_ORDER_RECIVED_DATE, 123)
where Order_Install_ID = '161'