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

Dat format

Status
Not open for further replies.

cpitc

IS-IT--Management
Dec 20, 2009
77
GB
I have created a table using this small script

CREATE TABLE Employee
(
Empid smallint not null,
Lname nvarchar(50) null,
Fname nvarchar(50)null,
City nvarchar(50) null,
DOB datetime null,
JobNum smallint not null
)

I then have created a record using this script


INSERT INTO Employee (Empid, fname, lname, city, dob, jobnum)
VALUES (1 ,'Colin', 'Preston', 'Leeds', 01/08/1962, 1)


However when I view the record the date looks like this

1900-01-01 00:00:00.000

I have tried to update it but I cannot get it to put in the correct date.

1. How do I get it so it show the correct date
2. Is there a way to set the date format when creating a table so it is just date and with format like 08/01/1962

Thanks

 
No datetimes are always keep the same time. Representation of the datetimes is your frontend job.
In SQL Server you could use SET DATEFORMAT to see the query result in proper formatting, check SET DATEFORMAT in BOL for more information.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
You need to put single quotes around your dates, just like you do for strings.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
insert into Employee values (1, cast('08/01/1962' as date as 'DOB'), 1);
go
That might work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top