Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 insert current year

Author  Topic 

shanmugaraj
Posting Yak Master

219 Posts

Posted - 2006-03-30 : 02:10:39
how to insert current year into table,

I tried ,
insert into tablename values('','',year)

i also need to know how to insert month , day

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-30 : 02:40:10
to get current year use the getdate(). Getdate() will return the current date & time
select year(getdate())
select month(getdate())
select day(getdate())




KH

Choice is an illusion, created between those with power, and those without.
Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-30 : 02:58:26
or

select datepart(year,getdate())

Also, why do you want to store day, month and year in seperate columns?
Use Datetime datatype to store dates and use format function in Front End application to format it to the way you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -