Default date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi experts,
I am developing an application, I am using vb 2005 and access.
I have many date fields, When I am saving through Query for default date I
save 1/1/1500 so when i find that date agian I know its a blank date.

Now The problem is when i attach Dataset to a datagridview, grid will show
date 1/1/1500, I don't want to show that date to user.
Is there any way I can have blank date in data grid when it finds 1/1/1500
as date.
Thanks for any answers
 
Rizwan,

Is there any reason that you use 1/1/1500 the nothing date in net is
01/01/00 and in Access 01/01/1753 (Eu and US notation)

A null value in the database is as well very well because you can use that
in the gridstyles or in the bindingevents.

Cor
 
Hi Cor Ligthert,
Thanks for ur reply, there is no particulat reason for me to use 1/1/1500 as
default date.

I tried what you suggested, I set date to nothing so when it saved in
database the value it got was 12:00:00am which is normal.

But then i load that into a datagrid then i see the date as 30/12/1899.
Is there any way to check if the date is 30/12/1899 then show blank in
datagrid.

or someother way to achive that.
Thanks
 
Hello Rizwan,

Set the database to allow null values in the date fields. Then pass DbNull.Value
into the database for dates that are not available.

-Boo
 
Hi GhostInAK,
Whwn I am passing the values in access in update query i write
mydate = #" & dbnull.value & "#

this generates an error.
Syntax error in date field in query expression '##'

So that doesn't work.
Thanks for help
 
Hi

In your query string you just need to have

mydate = null

instead of
mydate = #" & dbnull.value & "#

Hope that helps
Martin
 
Hi Pritcham,
I am able to save a null date to access database, and the value i can see
there is 12:00:00am.

The problem now I have is when i write a query to load in datagridview , the
value I see in datagrisview is 30/12/1899 .
I don't want to show any value for null date in grid , it should be blank.

Thanks for all ur help and replies.
 
Rizwan,

Don't trust the VBNet debugger about dates and times, it is giving a
translated DateTime in US notation, which is in my opinion very confusing
outside the US. The C# debugger does it correct.

Cor
 
Thanks Guys for all your help.
I solved the problem, I am posting this so that if someone is having similar
problem then he can use this.

i created a sub routine and called this sub just after assigning dataset to
datagrid.

Private Sub FilterDatefield(ByVal columnNumber As Int16)
Dim i As Integer
For i = 0 To grdJobs.Rows.Count - 1
If grdJobs.Rows(i).Cells(3).Value = "1/01/1500" Then
grdJobs.Rows(i).Cells(3).Value = ""
End If
Next
End Sub

thanks again.
Bye
 
Back
Top