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. Database & SysAdmin
  3. Database
  4. Datetime problem on sql statement

Datetime problem on sql statement

Scheduled Pinned Locked Moved Database
questiondatabasecsharphelp
3 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.
  • G Offline
    G Offline
    Gamoss
    wrote on last edited by
    #1

    Hi folks, Pretty newbie on everything and here goes my first question. I could not find similar question, but if someone has asked this allready before, please give me a link where to find answer to my problem :) So I have this problem that I'm trying to get Year from a database into a dataset. So how can I separate year from the datetime value in the sql statement? I have tried SUBTRING and EXTRACT but those are not working at all. I'm doing my project with vb.net Below is the sample I've tried with no luck. select firstname + ' ' + Lastname As Name, EXTRACT(YEAR FROM Birthday) as Year, Email from CardTable ORDER By Cardnumber Asc Gamoss, Icq: 32048647

    J 1 Reply Last reply
    0
    • G Gamoss

      Hi folks, Pretty newbie on everything and here goes my first question. I could not find similar question, but if someone has asked this allready before, please give me a link where to find answer to my problem :) So I have this problem that I'm trying to get Year from a database into a dataset. So how can I separate year from the datetime value in the sql statement? I have tried SUBTRING and EXTRACT but those are not working at all. I'm doing my project with vb.net Below is the sample I've tried with no luck. select firstname + ' ' + Lastname As Name, EXTRACT(YEAR FROM Birthday) as Year, Email from CardTable ORDER By Cardnumber Asc Gamoss, Icq: 32048647

      J Offline
      J Offline
      Jeremy Oldham
      wrote on last edited by
      #2

      What database are you using? If you are using MS SQL Server then you would have the following: SELECT firstname + ' ' + Lastname as Name, Year(Birthday) as Year, Email FROM CardTable ORDER BY Cardnumber Asc Jeremy Oldham

      G 1 Reply Last reply
      0
      • J Jeremy Oldham

        What database are you using? If you are using MS SQL Server then you would have the following: SELECT firstname + ' ' + Lastname as Name, Year(Birthday) as Year, Email FROM CardTable ORDER BY Cardnumber Asc Jeremy Oldham

        G Offline
        G Offline
        Gamoss
        wrote on last edited by
        #3

        Yes that was the server and it worked. That was really a fast reply. Thanks a lot! Gamoss, Icq: 32048647

        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