473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1291
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
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...
7
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...
19
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...
10
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.)>= #" &...
3
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. ...
4
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...
1
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...
4
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...
10
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.