December 13, 2007 at 2:02 am
Hi all,
I posted some posts recently, and now I have another problem.
I have a sql database named Baptism, to store baptism records in church I worked 1 year ago. I've got a table called dates, with those columns:
DateID, int, NOT NULL
BirthDate, smalldatetime, NOT NULL
BaptismDate, smalldatetime, NOT NULL
I put about 25.000 records in that table, with date/time format like:
01.01.2001 00:00:00
I live in Serbia, and I need to store date/time data in simple format like
01.01.2001 without time added.
I know that this should be done by using SELECT convert statement, but I'm not quite sure how to create that statement?
Please help me out
December 13, 2007 at 2:25 am
In SQL Server 2000 and 2005 there is no date datatype (2008 introduces this, but it is not yet out). So dates can be stored together with a time part in a datetime or smalldatetime type (or in a more ad hoc format, like varchar, int ... , but that is a different story). So in terms of storage, if you use datetime and smalldatetime you will be storing the time information.
You can use convert() to display the dates in a specific format. Have a look at Book Online http://msdn2.microsoft.com/en-us/library/ms187928.aspx (CAST and CONVERT (Transact-SQL) )
As an example, you can display (cast the datatime data to a varchar) like:
select convert(varchar, BirthDate, 104) from dates
This will return you varchars in the format:
01.01.2001
Regards,
Andras
December 13, 2007 at 3:27 am
alter table your table name alter column dd varchar(10)
update your table name set dd= convert(char(10),getdate(),102)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply