473,795 Members | 3,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Entering dates in bound fields

I'm working with SQL Server 2005 and VB.Net. I only want to store the date
(not the time) in the DateTime field.

I have a text field that is bound to a DateTime field in SQL. When I run the
program, the field initially comes up blank for new records. I enter a date
(like "03/14/06") and save the record.

When I retrieve the record and display it again, the field shows "03/14/06
12:00:00 AM". Now, that's annoying (and I would like to not display the time)
but I could live with it, if I had to.

The problem is, if I leave the entry like that and save the record, I get an
error message about my date field being too long for the field size.
What?!?!?!? I let the database populate the field, I didn't change it, and
now it says it's not good to put back in the database?

How do I save a DateTime field properly into SQL Server 2005? That's the
most important question.

The secondary question is, how do I get a bound field to only show the Date
portion of the database data?

Mar 14 '06 #1
1 1309
Dave,

What you ask about the database is impossible. The SQL server has two
DateTime fields. One is the DateTime and the other the SmallDateTime. They
both exist from different calculated ticks. The fist start at 1-1-1853 (when
the British Empire started the Gregorian Calendar) and the other at 1900.

To use from those date the parts, you can seperate parts using he datetime
methods. By instance only the date portion of today is Now.Date

To use in a control the date as a string, you can use the IFormatProvider ,
see for that this page.

http://msdn.microsoft.com/library/de...classtopic.asp

That can be by instance by using the binding events or by using column
styles.

I hope this helps,

Cor
Mar 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1351
by: GMG | last post by:
By providing a DTD in an XML document which is bound to HTML controls, Internet Explorer will automatically format the display of the date fields. For example 2004-08-03T00:00:00 will be displayed as 08/03/2004. It is a fantastic feature, but how does it determine which format to display it in ? The format that is being displayed on the samples I am looking at does not match my regional settings. All the dates are displayed in US format...
7
5126
by: smcgouga | last post by:
Visual Basic 6. ADO 2.8 I have an as400 DB2 V5R1 datasource. Dates are defined as *ISO format and have a range from '0001-01-01' to '9999-12-31'. I am trying to update a date field on the database with a value of '0001-01-01' (*LOVAL) The problem is that I need to use ADO cursors and can not use the SQL update command: "update tbl set dateField = '0001-01-01 where ..." (note this works no problem)
19
4110
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
10
9906
by: John | last post by:
Hi I have a form with tow fields for dates in dd/mm/yyyy format. I am trying to use the fields in a query's where clause as below; "SELECT * " & _ "FROM Orders " & _ " WHERE Orders.)>= #" & Format(!!, "dd/mm/yyyy") & "# And Orders.<= #" & Format(!!, "dd/mm/yyyy") & "# "
3
2070
by: cyber0ne | last post by:
I'm designing a basic form for data entry into one main table. There are two fields in the table that I would like to be automatically populated, not user-entered, when the record is posted. One is the current system time as a Date/Time value, the other is the current system username as a Text value. Being _completely_ new to MS Access, how/where do I set the form to do this when it posts a record? Also, can I distinguish between an...
4
3432
by: JayV | last post by:
I've created a data entry form. I have multiple fields but the fields "Road Log #" and "Road Name" I want to be bound to each other. I also have a table that lists out 1200 road log numbers and their corresponding road log names. I want the number that is entered into "Road Log #" to auto populate the "Road Name" with the correct name from the table. Help? I don't know much about the expression builders. But I tried messing around with things...
1
2245
by: josecruz | last post by:
I have to create a summary report that will provide counts and # average of days for multiple "Status" by entering different dates for every criteria. I have created several queries that calculates the number of days and the counts. I have created the corresponding report to show the sum and verages. But I don't know how to make them print on a main report that will display the information of multiple status since I have to enter multiple...
4
3327
by: Jeff Goodman | last post by:
If there is a better newsgroup to post this in, please let me know. I am a relatively new VB.NET/SQL 2000 programmer. I am working with data imported into SQL2K from Access. Many of the dates are null, such as the terminate date with current employees. I have written the search function to find a certain employee, and now I am editing the selected records. Several of the fields are date fields, and I am trying to format them so...
10
1465
tuxalot
by: tuxalot | last post by:
I have a table (TblDateHistory) to record lost days due to injuries: EmployeeID StartDate ReturnDate RestrictedOrLostDays TotalDays 1 ... ... Lost Time Days 36 1 ... ... Restricted / Transfer Days 50 2 ... ... Lost Time Days 10 3 ... ... Restricted / Transfer Days 8 1 ...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.