Correct way of storing a date?

  • Thread starter Thread starter Tarun Mistry
  • Start date Start date
T

Tarun Mistry

Hi, i am trying to store a users date of birth, within my application i will
store it as a datetime object, however what is the best way to store it in
the database (SQL SERVER)?

Thanks for any help!
Regards
Taz
 
Hi, thanks for your reply.

Icannot find this method on msdn, could you elaborate slightly?

Kind regards
Taz
 
SqlCommand command = new SqlCommand("INSERT INTO Table(dateColumn) values(@dateColumn)");
SqlParameter parameter = new SqlParameter("@dateColumn", SqlDbType.DateTime);
parameter.Value = DateTime.Now;
command.Parameters.Add(parameter);
 
Many thanks!

Appreciate your help,
Regards

Oytun Yilmaz said:
SqlCommand command = new SqlCommand("INSERT INTO Table(dateColumn)
values(@dateColumn)");
SqlParameter parameter = new SqlParameter("@dateColumn",
SqlDbType.DateTime);
parameter.Value = DateTime.Now;
command.Parameters.Add(parameter);
 

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

Back
Top