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. General Programming
  3. C#
  4. dates

dates

Scheduled Pinned Locked Moved C#
databasecsharpquestion
5 Posts 4 Posters 1 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.
  • A Offline
    A Offline
    aPerfectCircle
    wrote on last edited by
    #1

    I'm trying to get data from a sql database , calling a stored procedure that take 2 parameters date1, date2, I declared date1,date2 as string in my c# application, do I have to declare them as date type?, if so whats the data date type in c## ??? thanks in advance ,:)

    aPerfectTool

    C S A A 4 Replies Last reply
    0
    • A aPerfectCircle

      I'm trying to get data from a sql database , calling a stored procedure that take 2 parameters date1, date2, I declared date1,date2 as string in my c# application, do I have to declare them as date type?, if so whats the data date type in c## ??? thanks in advance ,:)

      aPerfectTool

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      DateTime is the date type in C#.  You can use ToString to store the date as a string, but then you can't do much with it, beyond display it.

      1 Reply Last reply
      0
      • A aPerfectCircle

        I'm trying to get data from a sql database , calling a stored procedure that take 2 parameters date1, date2, I declared date1,date2 as string in my c# application, do I have to declare them as date type?, if so whats the data date type in c## ??? thanks in advance ,:)

        aPerfectTool

        S Offline
        S Offline
        saqib82
        wrote on last edited by
        #3

        Hi there is no need to declare date1, date2 as datetime data type in c#. just declare them as string. while you are querying the data from the sql database using the stored-procedure, just do some casting to fetch the data from the database. e.g select * from tablename where ( convert(nvarchar, firstdate) = date1 regards

        sAqIb "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

        1 Reply Last reply
        0
        • A aPerfectCircle

          I'm trying to get data from a sql database , calling a stored procedure that take 2 parameters date1, date2, I declared date1,date2 as string in my c# application, do I have to declare them as date type?, if so whats the data date type in c## ??? thanks in advance ,:)

          aPerfectTool

          A Offline
          A Offline
          aamironline
          wrote on last edited by
          #4

          I would suggest you to use DateTime because it will be more convanient...

          M Aamir Maniar aamirOnline.com

          1 Reply Last reply
          0
          • A aPerfectCircle

            I'm trying to get data from a sql database , calling a stored procedure that take 2 parameters date1, date2, I declared date1,date2 as string in my c# application, do I have to declare them as date type?, if so whats the data date type in c## ??? thanks in advance ,:)

            aPerfectTool

            A Offline
            A Offline
            aPerfectCircle
            wrote on last edited by
            #5

            Thanks for all the answers, I got my problem fixed by declaring date1, and date2 as DateTime and by changing the data type in the column date from datetime to smalldatetime :cool:

            aPerfectTool

            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