General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 30th, 2003, 12:54 AM
Vantera Vantera is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: South Coast of NSW, Australia
Posts: 108 Vantera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Vantera
What's the DateTime equivalent of null or empty?

I have an Order class which includes the properties DateSubmitted, DatePaid, and DateShipped. Before the order is paid the DatePaid property (and DateShipped) should be null or empty which means that the order hasn't been paid for (and same with DateShipped).

How can I set these properties to null or empty or something? The properties correspond with nullable fields in the DB.

One possibility may be to assign 'new DateTime(0);' to them (the 0 being for the ticks parameter) but that would be tough to check later when I need to know if it is null or not.

Anyone got any ideas?
__________________
Kind Regards,
John Rebbeck
john@interspire.com
ICQ# 74637937

Reply With Quote
  #2  
Old June 30th, 2003, 02:12 PM
neoxean neoxean is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 5 neoxean User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
in PHP, 0 is null.

Reply With Quote
  #3  
Old June 30th, 2003, 10:55 PM
Vantera Vantera is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: South Coast of NSW, Australia
Posts: 108 Vantera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Vantera
Isn't that because PHP uses a timestamp? Or is that just mySQL?

I've tried the following and it does NOT work:

Code:
order.DatePaid = 0;
//or
order.DatePaid = (DateTime)0;


...so I need to figure out something else.

Reply With Quote
  #4  
Old June 30th, 2003, 11:21 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Can't you just set it to equal NULL?
It's a fairly standard thing to do across all languages.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #5  
Old July 1st, 2003, 12:21 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
set the field to null,....then when you add a row, don't submit that particular field and it will insert as null.
__________________
-- Jason

Reply With Quote
  #6  
Old July 1st, 2003, 11:19 PM
Vantera Vantera is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: South Coast of NSW, Australia
Posts: 108 Vantera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Vantera
Quote:
Can't you just set it to equal NULL?
It's a fairly standard thing to do across all languages.


You can't set null to a property of type DateTime because it is a value type.

Quote:
set the field to null,....then when you add a row, don't submit that particular field and it will insert as null.


I'll try that but there has to be a way to set it to null, otherwise MS really buggered up.

Thanks guys.

Reply With Quote
  #7  
Old July 2nd, 2003, 12:54 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
MS?! This is the PHP forum.

To set a DB value to null, it's like this:
UPDATE table SET datefield = NULL.

You said you were trying to do something with a class, that i presume you wrote? Is your problem with SQL or PHP code?

Reply With Quote
  #8  
Old July 2nd, 2003, 04:01 AM
Vantera Vantera is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: South Coast of NSW, Australia
Posts: 108 Vantera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Vantera
It's also the C# forum. I know how to set the data field to null but I need to set a C# class property of type DateTime to null.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > What's the DateTime equivalent of null or empty?


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 6 hosted by Hostway
Stay green...Green IT