Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A tricky date question...

Status
Not open for further replies.

JennyPeters

Programmer
Oct 29, 2001
228
US
Here's the scenerio:

I need to append records from one table1 to table2.

I need the date to change from full datetime data, '11/13/03 12:23:43 AM' to just '11/13/03'.

In other words, in my INSERT statement I need some syntax that will remove the time portion of the date, and only insert the 'date' portion.

Before you reply:
1. It's not a format issue. It's a data issue.
2. DATEPART is great to remove the month, day, year etc, but how would you add these parts together to make a date that inserts correctly.

Please help!
 
insert into table1 (yourdate)
select convert(varchar(10), yourdate, 101) as adate
from table2

Format the date from the from table to strip off the time. see above example.


 
Thanks Cmmrfrds!

It worked wonderfully.

Question: Is the 101 value a specific date format then?

Jenny
 
Yes, the 101 is a Style which is similiar to the Short Date format in access. Look up the Convert Function is sql server help and there is a table of all the Styles - someplace in help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top