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. Question about dates

Question about dates

Scheduled Pinned Locked Moved C#
questioncsharpdatabasehelptutorial
5 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.
  • H Offline
    H Offline
    harcaype
    wrote on last edited by
    #1

    I am trying to compare dates from my C# project file to the dates from my database. What I want to achieve is to check if the same date occured in the database. How do I do this? For example I want to check if DateTime.Now already existed in the database. I am trying to read it from there, however I need only the date, not the time. I have to omit this, because my plan was to convert them to strings and then just compare if they existed already. Can anyone help?

    S 1 Reply Last reply
    0
    • H harcaype

      I am trying to compare dates from my C# project file to the dates from my database. What I want to achieve is to check if the same date occured in the database. How do I do this? For example I want to check if DateTime.Now already existed in the database. I am trying to read it from there, however I need only the date, not the time. I have to omit this, because my plan was to convert them to strings and then just compare if they existed already. Can anyone help?

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #2

      just call .Date on the date object.

      DateTime.Now.Date

      Simon

      H M 2 Replies Last reply
      0
      • S Simon P Stevens

        just call .Date on the date object.

        DateTime.Now.Date

        Simon

        H Offline
        H Offline
        harcaype
        wrote on last edited by
        #3

        LOLZ!!! Stupid me! Thanks!

        S 1 Reply Last reply
        0
        • H harcaype

          LOLZ!!! Stupid me! Thanks!

          S Offline
          S Offline
          Simon P Stevens
          wrote on last edited by
          #4

          :laugh: No worries. It's easily missed if you don't know it's there.

          Simon

          1 Reply Last reply
          0
          • S Simon P Stevens

            just call .Date on the date object.

            DateTime.Now.Date

            Simon

            M Offline
            M Offline
            Mirko1980
            wrote on last edited by
            #5

            The same can also be done by calling DateTime.Today

            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