Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to pass Date format "mm/dd/yyyy " to Sql Stored procedure

how to pass Date format "mm/dd/yyyy " to Sql Stored procedure

Scheduled Pinned Locked Moved C#
databasecsharpsql-serversysadminhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zapss
    wrote on last edited by
    #1

    Dear all am new to c#(2008). i created a stored procedure in sql server 2000. "select * from employee where joindate between @d1 and @d1" I was using Table Adapter fill,get methods. when i tried to pass the date value which in "MM/dd/yyyy" it raises error message invalid datetime,then i declared DateTime variable and use Datetime.Parse(date in "MM/dd/yyyy"), DateTime.Parseexact,error not a valid datetime. i use Culture info ("en-US"),but no luck.

    A M 2 Replies Last reply
    0
    • Z Zapss

      Dear all am new to c#(2008). i created a stored procedure in sql server 2000. "select * from employee where joindate between @d1 and @d1" I was using Table Adapter fill,get methods. when i tried to pass the date value which in "MM/dd/yyyy" it raises error message invalid datetime,then i declared DateTime variable and use Datetime.Parse(date in "MM/dd/yyyy"), DateTime.Parseexact,error not a valid datetime. i use Culture info ("en-US"),but no luck.

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      use Convert(DateTime, '12/31/1920', 101) to convert properlt to datetime. Here 101 means you are passing in MM/dd/yyyy format. Check http://msdn.microsoft.com/en-us/library/aa226054(SQL.80).aspx[^] for more. :rose:

      Abhishek Sur My Latest Articles Working with Excel using MDAC
      Basics on LINQ and Lambda Expressions
      Create .NET Templates

      1 Reply Last reply
      0
      • Z Zapss

        Dear all am new to c#(2008). i created a stored procedure in sql server 2000. "select * from employee where joindate between @d1 and @d1" I was using Table Adapter fill,get methods. when i tried to pass the date value which in "MM/dd/yyyy" it raises error message invalid datetime,then i declared DateTime variable and use Datetime.Parse(date in "MM/dd/yyyy"), DateTime.Parseexact,error not a valid datetime. i use Culture info ("en-US"),but no luck.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        I hope you are NOT storing your date values as varchar in the database, you would be committing a major offence doing that. I use paramerterised queries and pass a date type into the sp. If I have to pass a string of a date to a proc I use 106 = "dd MMM yyyy" there is NO ambiguity in that format.

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups