I tried your line of code for my form in 3 different date fields and it did not drop the time that automatically populated as 12:00:00 AM. Thanks for the suggestion and example.
Main Topics
Browse All TopicsI am building a website in ASP.Net, Visual Studio 2005, with an Access database and C# code behind. I have many date fields and time fields on my forms and am using Date/Time fields in access. When entered they are 08/03/2009 or 15:49, but when they are brought back into the QC form for edit they come back in as "08/03/2009 15:49" for the date field and "08/03/2009 15:49" for the time field. How do I limit my date to just the date and time to just the time? I am putting the date and time data into text boxes or labels but have not been able to code it to be just date or time for each field.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
This site has some better examples.
http://msdn.microsoft.com/
For a time I'm going to put a T in for the modifier.
<asp:Label ID="EventDateLabel" runat="server" Text='<%# Bind("EventDate", "{0:T}") %>'></asp:Label>
This should yield something similar to 3:51:24 PM
Is that what you are looking for?
Neil Squires
Below is what I added to my code to try to get only the date to come into my text box from my Access database. In the form I am entering only the date in the format "08/11/2009". The table is adding 12:00:00 AM to the end of this entry when it is submitted. Then on my time entries I am entering 13:30 for 1:00 PM and the table is adding today's date in front of the time I have entered. When I querie the table for the date fields and time fields I am getting the full date and time in the date text box and the full date and time into my time text boxes into my form. I need to trim off these entries or better yet not have them auto populate into the table with the added date or time to the perspective fields.
Tillie,
In Access the DateTime datatype stores both Date and Time, so there is really no way to completely remove the time. You control what users see by the format that is applied to the DateTime value. On your access forms, to control what the user sees, do the following.
1. Open the form in design view.
2. Open the properties window.
3. Give the textbox with the date the focus.
4. On the properties window, go to the format tab.
5. In the attribute labeled "Format", click the dropdown list and determine how you want the date viewed. You can choose date, or time, or both as well as some additional formatting options.
This will allow you to control how a textbox in Access with a Date/Time value is viewed / entered.
HTH.
Neil Squires
What has probably happened is that when your tables were setup the fields weren't given a format.
Go into your table design and select your date column and use the Format line to pick the desired date format that you want. Repeat that for your Time columns being a Time format instead.
Then after you have done that you may still need to run update queries to clean up the existing data. Test this on a backup before doing to production.
Your queries would be like below.
Business Accounts
Answer for Membership
by: neil_squiresPosted on 2009-08-06 at 20:14:08ID: 25039786
Hi there.
en-us/libr ary/az4se3 k1(VS.71). aspx
Here's an example of how to get a date field to show just the date.
<asp:Label ID="EventDateLabel" runat="server" Text='<%# Bind("EventDate", "{0:D}") %>'></asp:Label>
You'll notice the second parameter within the bind, separated by the comma. After the colon is where you put the format that you want.
Here is a line you can follow to see all the different modifiers.
http://msdn.microsoft.com/
Hope that helps.
Neil Squires