473,795 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Formatting Dates and Null Handling

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 they display just dates, not dates and times.
I have data bound the fields from the stored procedures to the controls on
the edit page, but I do not seem to be able to apply a format to them.

In addition, if the dates come from the database Null and the user does not
change them I want to the leave the field null. But I cannot find a way to
a pass a parameter to the store procedure to represent this Null.

Any help would be appreciated.

Jeff G.

May 14 '07 #1
4 3327
Try: dbNull.Value

"Jeff Goodman" <jg******@storm central.comeond ownwrote in message
news:eA******** *****@TK2MSFTNG P02.phx.gbl...
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 they display just dates, not dates and
times. I have data bound the fields from the stored procedures to the
controls on the edit page, but I do not seem to be able to apply a format
to them.

In addition, if the dates come from the database Null and the user does
not change them I want to the leave the field null. But I cannot find a
way to a pass a parameter to the store procedure to represent this Null.

Any help would be appreciated.

Jeff G.

May 14 '07 #2
Jeff,

There are no "Date" fields in SQL server, Access, Windows or Net. It are all
DATETIME field whatever name they have. If you get them withouth a time,
than you have probabably tranformed them to strings or something like that.

Cor
"Jeff Goodman" <jg******@storm central.comeond ownschreef in bericht
news:eA******** *****@TK2MSFTNG P02.phx.gbl...
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 they display just dates, not dates and
times. I have data bound the fields from the stored procedures to the
controls on the edit page, but I do not seem to be able to apply a format
to them.

In addition, if the dates come from the database Null and the user does
not change them I want to the leave the field null. But I cannot find a
way to a pass a parameter to the store procedure to represent this Null.

Any help would be appreciated.

Jeff G.

May 14 '07 #3
Take the value you get from the database field and do something like this:

DateValue = Date.Parse(dbDa teTime).ToShort DateString
-or-
DateValue = Date.Parse(dbDa teTime).ToLongD ateString

"Jeff Goodman" <jg******@storm central.comeond ownwrote in message
news:eA******** *****@TK2MSFTNG P02.phx.gbl...
Several of the fields are date fields, and I am trying to format them so
they display just dates, not dates and times.

May 14 '07 #4
Thank You for your suggestions.

I will give them a try.

Jeff
May 22 '07 #5

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

Similar topics

2
1745
by: Patricia May | last post by:
Hi Being new to mysql I have some queries about formatting a date column 1. Can I use dd-mm-yy, my website is Australian 2. Can I leave the date field in one row empty if the date is unknown. 3. If I only know the year an event took place, can I enter just the year.
3
421
by: kmcnet | last post by:
Hello Everyone and thanks for your help in advance. I am developing an application that utilizes a separate class library for data access to a SQL Server database. One of the tables has several fields defined as DateTime. The data access layer exposes properties for each field in the table. In the instance of datetime fields, the class returns a property of date type. The problem occurs when one of the datetime fields is NULL, which results in a...
2
1190
by: Sara | last post by:
The problem: Conditional formatting bold, red when field Value < date() sets the field background to white - always - whether condition is met or not. I want the field unfilled and just red/bold when the date has passed. Background: I have 2 related fields that are only rarely active, so I manage them in the query for the subform: ShowBlanket: IIf(,"Blanket","") and
5
8188
by: Fernando | last post by:
Hello, I want do a program what find the date of the one before day at day what the program run (if today is 20031030, the program will find 20031029). I have the next: #include <stdio.h> #include <time.h> int main() { struct tm *ptr;
6
2503
by: Rookie Card | last post by:
I know this is a very common issue but cannot find a thread that resolves the issue. I need to re-format my dates to "MMM d, yyyy". The problem I have is I have an MSSQL database that allows <NULLS>. I'm using this code to format the dates: <%# IIF((dsCase.FieldValue("inj_beg", Container) <> nothing),DateTime.Parse(dsCase.FieldValue("inj_beg", Container)).ToString("MMM d, yyyy"), "") %>
2
4516
by: Yog | last post by:
Is there a best way to handle various formats of dates for SQL server?. The data comes in various input files with different date formats. The ParseExact function looks like an "evil" and it doesn't seem to work for some cases. 'Date Time Stuff Dim dtarray As String() = _
7
3074
by: Middletree | last post by:
I am trying to display dates in a spreadsheet, but the dates need to be in a format that will allow them to be sorted in Excel. The datatype in the SQL Server database is datetime. In this case, I need to display the date only, not the time. But I don't want to change the datatype in the database because the time is used in other places. So what I am doing is pulling it out of the database, then modifying it in ASP/VBScript by using the...
2
2198
by: Jim Carlock | last post by:
(1) Does PHP provide any way to handle dates prior to 1980? I know there's problems with Microsoft Windows NT and all Windows NT operating systems will allow a date prior to 1980 to be placed upon a file, but it ends up not being able to display the date (probably an Windows Explorer specific issue). (2) I'm looking for for ways to store dates and process dates (dates only). This probably ends up as a database specific issue, so I'm...
3
2115
by: myemail.an | last post by:
If I need to format how the content of a field is displayed, I can click ALT + ENTER from design view, and specify the format, for example, the number of decimal digits and so on. Is there a way to apply the same kind of formatting to more than one field at the same time? I tried selecting multiple fields, but if then I click ALT + ENTER I don't have the option to choose formatting. Also, how can I format dates as dates? I have a table...
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10448
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
10167
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
9046
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
7544
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
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
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.