[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Convert Access Short Date to SQLServer datetime

Posted on 2005-05-14
2
Medium Priority
?
1,768 Views
Last Modified: 2012-05-05
I would like to convert the following datetime dd/mm/yyyy format:

21/01/1997 00:00:00.000

to the following yyyy-mm-dd format without the time

1997-01-21

I have the following which switches the format:
UPDATE DATETABLE
SET DATE = CONVERT(DATETIME, (CONVERT(DATETIME,DATE,112)),105)

but am having trouble trimming the time from the field.
0
Comment
Question by:servantis
2 Comments
 
LVL 5

Accepted Solution

by:
waelothman earned 500 total points
ID: 14003068
yoy can do that by

 SET DATE = CONVERT(DATETIME, (CONVERT(DATETIME,DATE,112)),105
 SET DATE = cast(year(DATE) as nvarchar) +  '-' + cast(month(DATE) as nvarchar) +'-' +cast(day(DATE) as nvarchar)
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 14003122
You need to use the ODBC (112) or ISO8601 (126) style, as in:

UPDATE DATETABLE
SET [DATE] = CONVERT(char(10), [DATE], 126)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question