|
-
Aug 20th, 2004, 04:16 PM
#1
Thread Starter
Hyperactive Member
SQL Server date...help!
I have a question. If I have a date in a textbox, but then delete it so it is blank. Then I update (save) it. When I open my form again and open that record, the date shows up like this: 1/1/1900
Why is that?
-
Aug 20th, 2004, 06:28 PM
#2
Re: SQL Server date...help!
Originally posted by brendalisalowe
I have a question. If I have a date in a textbox, but then delete it so it is blank. Then I update (save) it. When I open my form again and open that record, the date shows up like this: 1/1/1900
Why is that?
How are you passing the Date, in VB when you declare a variable as date, it assigns a intial value of 1/1/1900 so i think thats whats happening.
When you update it try passing Null. How are you updating, stored procedure or Front end SQL Query, also what Database are you using?
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Aug 22nd, 2004, 01:00 AM
#3
Thread Starter
Hyperactive Member
I am updating using Front End SQL and SQL Server. What should I do different?
-
Aug 22nd, 2004, 06:33 PM
#4
Originally posted by brendalisalowe
I am updating using Front End SQL and SQL Server. What should I do different?
Have you tried passing null value? See if that works and let me know.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Aug 23rd, 2004, 09:05 AM
#5
Thread Starter
Hyperactive Member
But how do you pass a null value? All I did was delete the value I had in the textbox so it was blank. Is there a better way to go about it?
-
Aug 23rd, 2004, 09:19 AM
#6
Originally posted by brendalisalowe
But how do you pass a null value? All I did was delete the value I had in the textbox so it was blank. Is there a better way to go about it?
e.g
if txtMyDate.text ="" then
sql= "Update MyTable set MyDate=null Where ID=" & ID
Conn.execute (sql)
end if
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Aug 23rd, 2004, 09:24 AM
#7
No Date = 1/1/1900
Null Date = 12/31/1899
This "arguement" has been hashed to deal more than once in these forums. It's the way MS decided to deal with such dates. Not sure why, but in theory, it's because you can't not have a date, the date "has to exist" it would be like not having time.... but that gets into exestencialism and other etherial thinking.
TG
-
Aug 23rd, 2004, 09:52 AM
#8
Fanatic Member
In my ASP pages, I intentionally set my date values to '01/01/1900' if the user didn't enter the date. When I perform my select statement I check if the date = '01/01/1900' and just return an empty string if it does since this is not a date we would use here to signify anything:
Code:
Select Case When myDate = '01/01/1900' Then ''
When myDate Is Null Then ''
Else Convert(varchar(10), myDate, 101) End'myDate'
From myTable
Where ID = @ID
If you consider doing it this way, you MUST convert the date to a character field (varchar, char), otherwise it will still return '01/01/1900'.
Chris
Master Of My Domain
Got A Question? Look Here First
-
Aug 23rd, 2004, 10:07 AM
#9
Thread Starter
Hyperactive Member
Thanks! It works perfect!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|