• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

Sql 2005- Query column / insert date

Have an existing table with a date column. There is no dates/data in the column.

Need to query column and insert current date into my query.  

I was trying

select getdate() as [Date]

Doesn't work with Sql 2005.

Thanks.
0
TechMonster
Asked:
TechMonster
  • 6
  • 4
1 Solution
 
MikeWalshCommented:
Show the full insert you are trying.

Getdate() does work in SQL Server 2005..
You should be able to do:

INSERT TableName
(DateColumn)
SELECT GETDATE()
0
 
Anthony PerkinsCommented:
>>Doesn't work with Sql 2005. <<
Can you elaborate what that means, does it:
A. Give you an error message, if so what is it.
B. Give you the wrong results, as in the time in Greenland.
C. Smoke starts emanating from your monitor evey time you use it.
0
 
MikeWalshCommented:
I am offended by your comments anthony..

Why does everyone have to pick on Greenland? Who is to say the time in Greenland is the wrong result???

<g>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Anthony PerkinsCommented:
Only if you live in NH :)

But seriously, I apologize to the questioner for my sarcasm, but the totally useless phrase "doesn't work" is a long time pet peeve of mine and I have seen three separate instances of it today alone.  What boggles my mind is that as software engineers we should be particularly sensitive to this and yet we are all guilty of using it.
0
 
MikeWalshCommented:
ahh I totally agree..

check out this thread I started in expert input

http://www.experts-exchange.com/Community_Support/ExpertCare/Input/Q_21873401.html


0
 
Anthony PerkinsCommented:
Yes, I had seen it (and where it originated).  Good idea, but what are the chances of it coming to fruition?
0
 
MikeWalshCommented:
probably as likely as us getting T-Shirts ;-)
0
 
TechMonsterAuthor Commented:
MikeWalsh,

Thank you for your response.  I have one question though.  Will not the code you listed insert the date into my table that I am quering?

INSERT TableName
(DateColumn)
SELECT GETDATE()

I only have read access to my table and was looking for a way to populate the current date into the blank column
only in my query.  I am actually making a new table from the old table I am quering from.



0
 
MikeWalshCommented:
sorry

so you are not doing an insert then do this:

SELECT columnName,columnName, getdate() as [Current Date], ColumnName
FROM TableName
0
 
MikeWalshCommented:
Well I am biased here, but I think I gave him the answer and explained the premise. He asked no followup so I believe my answer helped him. So I say force accept MikeWalsh
0
 
Anthony PerkinsCommented:
>>but I think I gave him the answer and explained the premise<<
I would concur.  Hopefully a Moderator will be kind enough to delete all my off-topic ranting and raving.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now