Adding field of ShortDate Format?

A

Andrius B.

Hi all,

I have such a problem. No usefull info on Internet :(

I have a table with several fields, and some of them are of type Date,
having format "Short Date".
At this time I want to add one new colums of type Date, with with short date
format.

I use ADO.NET. For adding the field I use such code:

MainConn.Execute ("Alter TABLE Table1 add column borndate Date")

Such thing of course specifies no Date format. Should I use smth like
"...add column borndate ShortDate" or smth else?

I would prefer not to use other objects like provided by Access or DAO.

Thanks in advance.
 
J

Jeff Gaines

At this time I want to add one new colums of type Date, with with short
date
format.

I never keep formatted dates in a database. If you keep the date as an
integer (number of days from a fixed start date) it is quicker to search
and do calculations on - and you can format it how you like once you have
extracted it.
 
M

Morten Wennevik [C# MVP]

Hi Andrius,

Just make sure you use an SqlParameter with the SqlDbType.Date to transfer
to/from .Net and Sql and you should be fine. Formatting is only relevant
when you want to display the dates, in which case you can use a DateTime
format in any way you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top