Forums » .NET » ASP.NET »

How to remove time from date getting data from data base and assign text box


Posted Date: 20 Jul 2011      Posted By:: Madhus Profile photo    Member Level: Silver    Member Rank: 1022     Points: 2   Responses: 6



How to remove time from date
getting data from data base and assign text box.

I want assign date to my text box but failed fill without time
how can i filter time
from my date field in date field in database
using data set.



Thanks,
Madhu




Responses

#621387    Author: Himanshu Patel      Member Level: Gold      Member Rank: 390     Date: 20/Jul/2011   Rating: 2 out of 52 out of 5     Points: 2

You can use Split function with separator as ' ' space.

String[] result = date.ToString().Split(' ');

Textbox1.Text = result[0].ToString();

Thanks and Regards,
Himanshu Bhensdadia
Microsoft Certified Professional(MCTS)


 
#621390    Author: Mahesh Nagar      Member Level: Gold      Member Rank: 587     Date: 20/Jul/2011   Rating: 2 out of 52 out of 5     Points: 2

convert first date-time to date
then assign to text box
or you can fetch data from database like this

select convert(varchar(10) , dt_field_name ,103)
from table_name


~~~~~~~~~~ Simply Making Effort ~~~~~~~
Thanks and Regard
Mahesh Nagar


 
#621395    Author: Pawan Awasthi        Member Level: Diamond      Member Rank: 4     Date: 20/Jul/2011   Rating: 2 out of 52 out of 5     Points: 2

Hi Madhu,

There are 3 ways to remove the time which is getting from the database.

1. While rereieving the date from the database, format the date in such a way so only the date part will come in the dataset and then you can assign it directly to the date textbox.

2. The other way is that with out touching the database, you just split the date with time from the space character and get the first part.

3. After getting the date with time as string, you can formt it at the fronend by converting it in to date and then convert it in to .toShortDate. it will get only the date without time.

Regards,
Pawan Awasthi(DNS MVM)
+91 8123489140
pawansoftit@gmail.com





 
#621398    Author: Manoranjan Sahoo      Member Level: Gold      Member Rank: 159     Date: 20/Jul/2011   Rating: 2 out of 52 out of 5     Points: 2

you can use below code to get only date part :

SELECT CONVERT(VARCHAR(10),GETDATE(),105)


it will show following result :
20-07-2011

If it helps you then Rate this.

Regards,
Manoranjan Sahoo
http://www.dotnetsquare.com


 
#621401    Author: Subhash.N      Member Level: Silver      Member Rank: 533     Date: 20/Jul/2011   Rating: 2 out of 52 out of 5     Points: 2

Hi Madhu

can you can the Date to textbox

string dt=ds.Table[0].Row[0]["CreatedDate"].Tostring();
txtDate.Text=Convert.ToDateTime(dt).ToString("dd/MM/yyyy");


Or

In select Query


select convert(varchar, getdate(), 103)


Regards
N.Subhash


 
#621405    Author: Madhus      Member Level: Silver      Member Rank: 1022     Date: 20/Jul/2011   Rating: 2 out of 52 out of 5     Points: 1

Thank you all
its working





Thaks,
Madhu.


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Return to Discussion Forum
Start new thread

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India