Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 18th, 2005, 01:53 PM
abacus abacus is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 28 abacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 17 sec
Reputation Power: 0
ASP writing datetime to MS SQL (used to write to Access)

We have just begun the process of converting the datbase from Access 2000 to MS SQL Server 2000.

I want to be able to write a null value to a datetime field(column); but I always get 1/1/1900 for a value.

I want to be able to write a time value to a datetime field(column); but it is always prefixed with 1/1/1900.

Am I asking/attempting the impossible?!?

TIA,
Chuck

Reply With Quote
  #2  
Old April 18th, 2005, 02:11 PM
akinator akinator is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 7 akinator User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 39 m 55 sec
Reputation Power: 0
For the first NULL date value, you should be able to set the colum to 'NULL' or ''.

For the second, I belive the DateTime field will always have a date; you will just have to evaluate the time component on it's own using SQL Server's Date functions (i.e. DATEPART)

Is there a specfic reason that you need just a time component?
Comments on this post
abacus agrees!

Reply With Quote
  #3  
Old April 18th, 2005, 02:59 PM
abacus abacus is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 28 abacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 17 sec
Reputation Power: 0
Thanx, akinator!!!

Regarding the field where I want a <null> date: It is set to accept Nulls; and I'm writing only a pair of single quotes... but 1/1/1900 appears/is stored.

Regarding the 'time-only' field, in Access, it was just that (i.e. 8:00:00 AM); and it appears in the Employees record, once as 'Start Time' and again as 'Stop Time' (i.e. as empTimeStart, empTimeStop respectively). I can live with '1/1/1900 8:00:00 AM' but I have a bit of code to modify...and 'sides, it's not as aesethically pleasing... a bit of overkill where just a time value alone would suffice.

Are you able to write null to a datetime field?

Thanx for your rapid reply!!!

Reply With Quote
  #4  
Old April 18th, 2005, 03:02 PM
abacus abacus is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 28 abacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 17 sec
Reputation Power: 0
Whoops....

working on spelling aesthetically...

~grin~

Reply With Quote
  #5  
Old April 18th, 2005, 03:15 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
You should NEVER allow NULL values in SQL Server, it can seriously hinder query performance.
You should always set a default value on all of your columns.
Comments on this post
abacus agrees!

Reply With Quote
  #6  
Old April 18th, 2005, 03:54 PM
abacus abacus is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 28 abacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 17 sec
Reputation Power: 0
Never allow a NULL??? Never?

Granting that performance can take a hit, if NULLs are allowed, what would you recommend for a field where no value (i.e. <Null>) is more common than not... say a datetime field like Termination Date (empDateTerm)?

I really don't want a Date (datetime) of any sort/kind stored therein, as long as the employee is still on the payroll.

You suggest *NEVER*, but are there times when one should 'Never say never'?

I really don't know... I'm a nube, in transistion, from Access.

Reply With Quote
  #7  
Old April 18th, 2005, 05:36 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
Best Practices is as follows

Default values for data types:

any text (varchar, char, etc...) ('')
int (-1) or (0)
any decimal (decimal, money, etc...) (0.00)
datetime (1/1/1900)

Reply With Quote
  #8  
Old April 18th, 2005, 05:58 PM
abacus abacus is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 28 abacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 17 sec
Reputation Power: 0
Re: Defaults...

Memnoch,

Beaucoup thanx for your time & consideration. I read your 'Sticky Post' about MS SQL & NULLS.

Got a bunch o' ASP to tweak...

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > ASP writing datetime to MS SQL (used to write to Access)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT