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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Creating a SqlDbType.SmallDateTime parameter

Creating a SqlDbType.SmallDateTime parameter

Scheduled Pinned Locked Moved Database
2 Posts 2 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.
  • D Offline
    D Offline
    digsy_
    wrote on last edited by
    #1

    I'm trying to create a SqlDbType.SmallDateTime parameter and have been unable to find the correct answer. I'm trying to take a date in mm/dd/yyyy format from a text box and pass it to a stored procedure. This is about as close I have got but it still doesnt work: SelectCommand.Parameters.Add("@dateofbirth", SqlDbType.SmallDateTime).Value = DateTime.Parse(StoredProcedureValues[3]).ToShortDateString(); Does anyone know what the answer is ? Thanks

    M 1 Reply Last reply
    0
    • D digsy_

      I'm trying to create a SqlDbType.SmallDateTime parameter and have been unable to find the correct answer. I'm trying to take a date in mm/dd/yyyy format from a text box and pass it to a stored procedure. This is about as close I have got but it still doesnt work: SelectCommand.Parameters.Add("@dateofbirth", SqlDbType.SmallDateTime).Value = DateTime.Parse(StoredProcedureValues[3]).ToShortDateString(); Does anyone know what the answer is ? Thanks

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      When you are adding a datetime value of any sort to a database leave it in a date, I mean DATE, format if possible. Otherwise you must format it correctly to insert. So ensure that the value you are parsing to DateTime is a date value and dont set it to short date string. SmallDateTime is about precision not how it looks in the DB[^]


      CleaKO

      "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy
      "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

      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