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. Visual Basic
  4. Little problem in Vb.net

Little problem in Vb.net

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestioncsharp
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.
  • E Offline
    E Offline
    eshban284
    wrote on last edited by
    #1

    I have a field in SQlServer Database which name is "PublishingDate". In it, Date is stored in that format i.e 3/28/2005 In my vb.net program i use select query to fetch all the records of column "PublishingDate" I use the query below to just select year out of whole Date and display result in a combobox. "select distinct DATEPART(yy,publishingdate) from books" Everything will be fine. In Combobox it show all "years" like 2000,2001,2002,2003 I want that when user clicks on any year in a combobox like '2000', it will display results according to that query Select * from books where publishingdate='" & ComVal.text & "' But this query cannot display the result because in database date is stored in this format "3/8/2005" Hope you got the meaning. I use this query, but it cannot display the result. SELECT * From books where publishingdate IN (select Datepart(yy,publishingdate)from books) How can i do this? Plz help me in this regard. Eshban EsHbAn BaHaDuR

    C C 2 Replies Last reply
    0
    • E eshban284

      I have a field in SQlServer Database which name is "PublishingDate". In it, Date is stored in that format i.e 3/28/2005 In my vb.net program i use select query to fetch all the records of column "PublishingDate" I use the query below to just select year out of whole Date and display result in a combobox. "select distinct DATEPART(yy,publishingdate) from books" Everything will be fine. In Combobox it show all "years" like 2000,2001,2002,2003 I want that when user clicks on any year in a combobox like '2000', it will display results according to that query Select * from books where publishingdate='" & ComVal.text & "' But this query cannot display the result because in database date is stored in this format "3/8/2005" Hope you got the meaning. I use this query, but it cannot display the result. SELECT * From books where publishingdate IN (select Datepart(yy,publishingdate)from books) How can i do this? Plz help me in this regard. Eshban EsHbAn BaHaDuR

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

      I take it this means the date is stored as a string ? SELECT * From books where publishingdate LIKE '%/' + publishingyear Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • E eshban284

        I have a field in SQlServer Database which name is "PublishingDate". In it, Date is stored in that format i.e 3/28/2005 In my vb.net program i use select query to fetch all the records of column "PublishingDate" I use the query below to just select year out of whole Date and display result in a combobox. "select distinct DATEPART(yy,publishingdate) from books" Everything will be fine. In Combobox it show all "years" like 2000,2001,2002,2003 I want that when user clicks on any year in a combobox like '2000', it will display results according to that query Select * from books where publishingdate='" & ComVal.text & "' But this query cannot display the result because in database date is stored in this format "3/8/2005" Hope you got the meaning. I use this query, but it cannot display the result. SELECT * From books where publishingdate IN (select Datepart(yy,publishingdate)from books) How can i do this? Plz help me in this regard. Eshban EsHbAn BaHaDuR

        C Offline
        C Offline
        Chemisus
        wrote on last edited by
        #3

        have you tried this? Select * from books where year(publishingdate) = '" & ComVal.text & "'

        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