PC Review


Reply
Thread Tools Rate Thread

Checking if Date is Nothing

 
 
rcolby
Guest
Posts: n/a
 
      14th Aug 2004
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


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      14th Aug 2004
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(ByVal sender As _
Object, ByVal e As System.EventArgs) _
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.DataSource = dt
End Sub
///


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      14th Aug 2004
* "rcolby" <(E-Mail Removed)> 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/>
 
Reply With Quote
 
rcolby
Guest
Posts: n/a
 
      14th Aug 2004
Thanks for the advise, really getting into programming again.



"rcolby" <(E-Mail Removed)> wrote in message
news:411d4efc$0$196$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
date checking JaniN Microsoft Access 1 10th Apr 2008 05:48 PM
Checking a Date format =?Utf-8?B?S29idXM=?= Microsoft Excel Programming 1 12th Apr 2005 01:09 PM
Expiry Date Checking Mishap with Specific Date Regional Settings Orlin Pavlov Anti-Spyware Installation 1 18th Mar 2005 07:02 PM
Date checking Johnny Microsoft Excel Programming 2 27th Jul 2004 06:47 AM
checking what day a date is? neowok Microsoft Excel Programming 5 24th Jun 2004 12:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:50 AM.