Click here to Skip to main content
11,922,641 members (52,796 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


10 bookmarked

How to remove Time from DateTime on client side (aspx page)

, 23 Nov 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
It's a simple but helpful tip and it's easy to implement


Usually we put the Data Type for column named "date" as datetime or smalldatetime. So it will by default attach a date whether we pass any time with date or not. For example if we pass "datetime" it will take both date and time  like "11/23/2012 1:28 PM" and it we pass "shortdate" then it will take "11/23/2012 0:00 AM" so there is nothing we can do if the Data Type is "datetime" or "shortdatetime". I needed to get rid of time so i searched and found a good solution that i am trying to share with everyone.


Recently i was in the situation like i told in my introduction section. My Data Type in database field for "SignUpDate" is "datetime". So it's taking both date and time i have nothing to do with this. but i needed to show only the date at the front end. On the other hand i may also need the time it the client wants it for any reason so i can't delete it. so i need to find a solution that will hide the time while it renders the page.

Using the code 

Here is the screenshot of my database fields.


Here is the problem i faced.



I just wanted to remove the time from the display

Here is my code for the solution:

// <asp:BoundField DataField="SignUpDate" HeaderText="SignUp Date" DataFormatString="{0:d}" />


This is the command we need to add with our "<asp:BoundField />" tag

The output will be like this as i want Smile | :)   the time is removed from the display

Thanks and Happy Coding.


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


About the Author

Software Developer Cefalo
Bangladesh Bangladesh

I am Palash Debnath. I have been working on windows technologies since 2008. I started with ASP.NET. Then I moved to Windows Form and from the last year I have been working with Windows 8 app development. My future plan is to work with Windows 10 app development as well. I have completed my Undergraduate from Khulna University of Engineering in Computer Science & Engineering. Now I am working as a Software Engineer at Cefalo on Windows 8 app development.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151125.1 | Last Updated 23 Nov 2012
Article Copyright 2012 by dpalash
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid