Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
how to insert date from text box into datetime field without time

i have textbox1 with ajax calendar and when i have to insert selected date into datetime field

the inserted value is 4/5/2011 12:00:00
i don't want the time part
Posted

You can make the formatting at client side or you can embed it to the SQL statement. For example current datetime to date would be:
SQL
SELECT CAST(GETDATE() AS DATE)
 
Share this answer
 
Comments
shms_rony 5-Apr-11 15:26pm    
where can i do this statment ??
Wendelius 5-Apr-11 15:51pm    
You currently have somekind of SQL statement fetching the datetime fields. Something like:
SELECT MyDatetimeField, ... FROM ...
so you should change it to
SELECT CAST(MyDatetimeField AS DATE), ... FROM ...
shms_rony 5-Apr-11 16:08pm    
iam using wizard method :(

i want to format date in column properties if this right
Wendelius 5-Apr-11 16:10pm    
I'm sorry but I don't know what you mean by Wizard method.
shms_rony 5-Apr-11 16:15pm    
i mean that i display date from field in gridview by wizard method ...not using select statment
If you look at this page[^] on MSDN and examinr the code, you will find this:
XML
<asp:BoundField HeaderText="Price/Unit"
   DataField="UnitPrice" SortExpression="UnitPrice"
   DataFormatString="{0:c}">

that code formats the data for the 'Unit Price' column.

Unsurprisingly you can do a similar thing for Dates as well as for Currency.
On this page[^] you will find the various Format Characters and the second table lists those for date values. The first one is the one you would need.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900