forum

Home / DeveloperSection / Forums / Need output in dd/MM/yyyy format from table value pair

Need output in dd/MM/yyyy format from table value pair

Anonymous User185823-Dec-2013

Here is my code for passing table value pair to stored procedure. DOJ field is DateTime and in SP, DOJ field is date. Both are compatible. Output is like dd/MM/yyyy.

If DOJ field is DateTime and in SP, DOJ field is DateTime2(3), o/p is dd/MM/yyyy hh:mm:ss But I need o/p to be dd/MM/yyyy. How should i write the code ?

dt1.Columns.Add("DOJ", typeof(System.DateTime));

DataRow dr1 = dt1.NewRow();

dr1["DOJ"] = DateTime.ParseExact("02/03/2001", formats, us, DateTimeStyles.None);

// dr1["DOJ1"] = "12/13/2001";   if i use  this one it works .

dt1.Rows.Add(dr1);    // Get DOJ as - 3/2/2001 12:00:00 AM

ds1.Tables.Add(dt1);

Here is my stored procedure code -

-- CREATE TYPE StateTbls7 AS TABLE

( StateID   VARCHAR(200)

, StateCode VARCHAR(200)

, StateName VARCHAR(200)

, DOJ      date           

)

ALTER PROCEDURE sp_Add_contact

    (

      @ds1 StateTbls7 readonly

    )

AS

    begin

              declare @DOJ       VARCHAR(200)

          select @DOJ = d1.DOJ   from @ds1   d1

              select  @DOJ as 'a1'

    end

return


Updated on 23-Dec-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By