how to take only database ?
i want to take only date in one table in sql server 2005 db.for that when we select datetime as datatype it show it's default time also so what can i do for show only date . & if i want to show the current time (System time ) with date instead of default time what can i do?
Soft CornerPosted Mar 28, 2011, 8:37 AM
As per your requirement, you want to insert User Entered Date along with System Current time then try this :
DateTime time = DateTime.Now;
string FormatedDate = "11/02/11"+" "+time.ToLongTimeString(); //here replace your date which is entered by user
DateTime date = DateTime.Parse(FormatedDate);
and finally insert date obj into database, for e.g :
string query = "insert into TableName values('" + date + "')";
Suthish NairPosted Mar 28, 2011, 7:17 AM
select CONVERT(VARCHAR,column name,101) + ' ' + CONVERT(VARCHAR,SYSDATETIME(),108)
shree gunjalPosted Mar 28, 2011, 6:51 AM
i am taking date from user into my form,
according to system time , can it save current time along with the entering date into database .
Soft CornerPosted Mar 28, 2011, 4:03 AM
as per your question, when your inserting/selecting date only from datetime Use CONVERT(VARCHAR(30),ColumnName/Value,111)
and for current datetime , select convert(varchar, getdate(), 1)
Soft CornerPosted Mar 28, 2011, 3:45 AM
1. If binding data thro' SqlDataSource then in
Use DataFormatString = "{0:d}" , its a format pattern for GridView to display Short date
2. if Binding thro' SqlDataAdapter then in query Use
CONVERT(VARCHAR(30),ColumnName,111) , it will return date part from datetime
3. For displaying Date only from current Time
DateTime time = DateTime.Now;
Response.Write(time.ToShortDateString());
Amruta KirdatPosted Mar 28, 2011, 3:13 AM