Datetime problem on sql statement
-
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
-
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
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 -
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