Date getting displayed as some random number when it is null

Who is online?  0 guests and 0 members
Home  »  Forums   »  microsoft business intelligence   »  sql server   » Date getting displayed as some random number when it is null

Date getting displayed as some random number when it is null

Topic RSS Feed

Posts under the topic: Date getting displayed as some random number when it is null

Posted: 12/8/2011

Jedi Youngling 74  points  Jedi Youngling
  • Joined on: 11/28/2011
  • Posts: 27

Hello All,

I am having an issue with the date. I am having 2 tables one is raw and one is production. I need to load the production table with the raw table.Their definitions and the data both are same.But I just need to modify the data types when it comes to production table. I have a end_date column in the raw table which is varchar and  it has some values as null. I have defined the data type for my end_date in production table as Date. So when the end date comes to production it is inserting something like 1900-01-01 in place of null.But I dont want that value to be displayed like that. I want that value to be null. Any help is much appreciated.

Thanks


Posted: 12/8/2011

Jedi Master 5449  points  Jedi Master
  • Joined on: 1/21/2010
  • Posts: 227
Answered  Answered

sqlkala,

Traditionally, when you are loading a datawarehouse with data and there are no values found during a lookup operation a value assigned to the NULL record is returned. This is what is happening to you and the reason for you getting the 1900-01-01 date. That date is referred to many as a date assigned to the unknown record and is usually in your date dimension table as a datesk (surrogate key). In my opinion, I would keep this value if you want a date in the column. I would steer away from having NULL's in your table when possible due to the performance hit. If you really must have NULL in the column, (assuming you are using a sql query to pull the data since I didn't see any reference to see HOW you were loading the data) then you need to wrap the date column in question with ISNULL(datecolumn, NULL).

Good luck,

Brian K. McDonald, sqlbigeek

 

 


Posted: 12/8/2011

Jedi Youngling 74  points  Jedi Youngling
  • Joined on: 11/28/2011
  • Posts: 27

Thanks so much for the reply Brian. I used ISNULL and it worked.

Thanks again


Posted: 12/8/2011

Jedi Master 5449  points  Jedi Master
  • Joined on: 1/21/2010
  • Posts: 227
Answered  Answered

I"m glad it helped you. Can you please mark this as answered?


Page 1 of 1 (4 items)