Convert a Date Prior to Insert RRS feed

  • Question

  • I'm migrating Oracle to SQL Server and have unsuccessfully tried Convert and Cast several different ways to convert a user-entered date to appropriate format prior to insert.  Here is the old Oracle statement using to_date for the date conversion...what is the correct syntax (unsing convert or cast) for SQL?  Thanks.


    INSERT into table1 (grad_dt)

    VALUES (to_date('#form.course_date#', 'MM-DD-YYYY'))



    Thursday, August 7, 2008 5:03 PM


  • What does the date look like in its native format?  SQL is not all that picky  when you insert a date column into a table. 

    Code Snippet

    Convert(varchar(10),MyDtColumn,101) --mm/dd/yyyy



    Here is the BOL link.  It shows you how to transform dates.

    Thursday, August 7, 2008 5:15 PM