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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datetime in Sql Server

Status
Not open for further replies.

simma

Programmer
Sep 11, 2001
398
0
0
US
Hello,
I migrated a databse from access to sql server200.Frontend is in access and backend in sqlserver.Problem is if I enter dates its send to sqltable as datetime..How do I fix this to insert just dates from access to sql server?
Thanks
 
Try these:

Code:
SELECT CONVERT(VARCHAR(10), GETDATE(), 101)--will return 08/17/2004

SELECT CONVERT(VARCHAR(10), GETDATE(), 103) --will return 17/08/2004

--Style 101 is USA and 103 is British.

The above assume it is 17th August 2004 - todays date is not good to use in the examples - 09/09/2004 and 09/09/2004 will be returned

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
SQL Server 2000 only has the datetime and smalldatetime types for storing date information. However, if you only supply the date portion and not the time, then SQL Server will automatically append the time of midnight (00:00:00.000) to the date when storing. This can work perfectly well in your situation; just ignore the time portion of the datetime field, or use the Convert function as dbomrrsm did to "cut out" the time portion and return the date as a varchar.

HTH,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top