April 16, 2009 at 3:48 am
I have one temp table and the particular table I have to insert date value. And I have to insert records from various tables.some tables have the date values in date and time. some of tables having table value alone. Can i able to insert only the date values in the table without using convert in the select means can i alter that table column that can covert itself to date value though the records from the select having datetime? I have to chk the performance orience also. Please prefer me the best method to proceed.
Thanks in advance.
April 16, 2009 at 8:06 am
I'm sorry, but I really don't understand the question. Can you post a bit of sample code for what you're trying to do?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 16, 2009 at 8:13 am
Hi Kavin
It would great if you post Table structure, sample data and your requirement once with examples.
April 16, 2009 at 1:15 pm
Hi
If you want to remove the time part of a DATETIME column you can use this:
SELECT DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)
If you have a different problem I join the others sit down and wait for further information 🙂
Greets
flo
April 16, 2009 at 7:59 pm
Hi Flo,
You are very positive, to give some help on the question:-) I like that...
April 17, 2009 at 1:26 am
Let me explain the question briefly,
For example assume I have table
table 1 and it is having columns name,id,date (only the date values I have to insert)
I have 2 tables assume table2,table3
in table2 I have a date value column , In table3 I have column with both date and time.
I dont want to use convert statement in my select while inserting.
But I need only the date values from table at the time of inserting itself.
April 17, 2009 at 3:18 am
Hi
Did you try my example? Just copy to SSMS and execute.
In your SELECT just replace the GETDATE() with your column name.
Greets
Flo
April 21, 2009 at 12:03 am
What I find works quite well is the convert function. eg
select convert(varchar(11), getdate(), 106)
will return the date in the format dd MMM yyyy for the format specified (106 in this case)
there are many other formats to choose from.
Stephen
Stephen Marais
Integration Architect
Digiata Technologies
www.digiata.com
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply