473,545 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking if Date is Nothing

Hi all,

I'm experiecing a problem with dates being returned from SQL 2000 Database.
I retrieve the last updated field (Date) from a sql 2000 and then compare
the returned date with another record I'm checking against, to see if they
are the same or if the returned value is nothing, checking to see if the
date are the same works if not nothing. I have tried the following:

Dim datDate As Date = Nothing

If dteSQLUpdate = datDate Then

-----

If dteSQLUpdate = nothing

Thanks
Richard
Nov 21 '05 #1
3 6664
RColby,

Try this sample I just made, I hope that you than you see how the dates work
in a datatable in VBNet (and therefore in a database)?

Cor

\\\Needs a new project with a datagrid on the form
Private Sub Form1_Load(ByVa l sender As _
Object, ByVal e As System.EventArg s) _
Handles MyBase.Load
'Making of the test datatable
Dim dt As New DataTable("Test ")
dt.Columns.Add( "Dat", GetType(System. DateTime))
For i As Integer = 0 To 5
Dim dr As DataRow = dt.NewRow
dr(0) = Now.AddDays(i)
dt.Rows.Add(dr)
Next
'Showing handling of the date in a datatable
dt.Rows(0)(0) = DBNull.Value
For Each dr As DataRow In dt.Rows
If dr(0) Is DBNull.Value Then
dr(0) = Now.AddDays(10)
End If
Next
DataGrid1.DataS ource = dt
End Sub
///
Nov 21 '05 #2
* "rcolby" <rc*******@hotm ailPLEASEREMOVE .com> scripsit:
I'm experiecing a problem with dates being returned from SQL 2000 Database.
I retrieve the last updated field (Date) from a sql 2000 and then compare
the returned date with another record I'm checking against, to see if they
are the same or if the returned value is nothing, checking to see if the
date are the same works if not nothing. I have tried the following:


'Date' is a value type and cannot be 'Nothing'. Take a look at the
'SqlDateTime' data type.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3
Thanks for the advise, really getting into programming again.

"rcolby" <rc*******@hotm ailPLEASEREMOVE .com> wrote in message
news:41******** *************@n ews.zen.co.uk.. .
Hi all,

I'm experiecing a problem with dates being returned from SQL 2000 Database. I retrieve the last updated field (Date) from a sql 2000 and then compare
the returned date with another record I'm checking against, to see if they
are the same or if the returned value is nothing, checking to see if the
date are the same works if not nothing. I have tried the following:

Dim datDate As Date = Nothing

If dteSQLUpdate = datDate Then

-----

If dteSQLUpdate = nothing

Thanks
Richard

Nov 21 '05 #4

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

Similar topics

8
94974
by: Robert Mark Bram | last post by:
Howdy All! How can you tell the type of an object? I am not talking about using "typeof" .. I am talking about being able to determine if an object is a Date or String .... Thanks for any advice!
3
1473
by: JackO | last post by:
I have a text box on a form “txtExamDate” that I know contains nothing. I am trying to test code that will determine the text box is nothing. I am getting the error because there is no value in the field and I am assigning it to a date field. My question is: How do I get the If statement to work? Exception Details:...
13
25287
by: John A Grandy | last post by:
apparently references of type Date can not assume the value Nothing, because the following code fails: Dim d As Date .......other code...... If d Is Nothing Then End If so then what is the equivalent to Nothing for a reference of type Date ?
0
273
by: gsb58 | last post by:
Hi! I have a little problem with the registry function. The function is supposed to check the registry as the main form is activated. If there is a key it should not write to the registry, as it does. Can anybody see what I'm doing wrong? Private Sub WriteToRegistry() Dim regKey As RegistryKey = Nothing
2
11901
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a procedure. We weren't able to declare it with DateTime.MinValue as its default value, as MinValue is a read-only property rather than a constant. To...
4
2351
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw exceptions?
16
2594
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project where someone suggested to me I was spending too much time writing error messages, and that I was therefore missing the benefit of using a scripting...
1
1479
by: BerkshireGuy | last post by:
I have a Access database that should have data for each weekday of the year. There is a field called DateDownloaded, which should have at least one record for each weekday of the current year. Does anyone know of existing code that would check to make sure each weekday has at least one record and if not, write that date to a temp table or...
27
6801
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com to test the time zone offset on a variety of dates to see if it changes. Based on that, I developed the following checkDST() function which, as far as I...
0
7807
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7419
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...
0
5971
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5326
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...
0
4944
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...
0
3450
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...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
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...

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.