Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi

in my web application i have a textbox which contains a date

i need to send this date to the database

 

how i did that was like follows (In C#)

 

DateTime StartDate;

StartDate=DateTime.Parse(txtStartDate.Text).Date;

 

my problem is this is passing '2/10/2004 12:00:00 AM'

but i donot want to pass this whole thing bcos my sql storedprocedure doesn't work if i pass above whole thing.

 

i need to pass one the '2/10/2004' part

 

does any body have an idea

 

thank you very much in advance

Posted

Heres how to format dates in C#

 

System.DateTime.Now.ToString("dd/MM/yyyy");

 

You can format on the ToString method.

 

Using your method

 

DateTime StartDate;

StartDate = DateTime.Parse(textBox1.Text).Date;

whatever = DateTime.ToString("dd/MM/yyyy")

 

 

Andy

Code today gone tomorrow!
Posted

hi a_jam_sandwich

thx for replying

but this is converting the date to string

i want the type of the variable as datetime after formatting

thx

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...