|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
in PHP, 0 is null.
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
Can't you just set it to equal NULL?
It's a fairly standard thing to do across all languages. |
|
#5
|
|||
|
|||
|
set the field to null,....then when you add a row, don't submit that particular field and it will insert as null.
__________________
-- Jason |
|
#6
|
||||
|
||||
|
Quote:
You can't set null to a property of type DateTime because it is a value type. Quote:
I'll try that but there has to be a way to set it to null, otherwise MS really buggered up. Thanks guys. |
|
#7
|
||||
|
||||
|
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? |
|
#8
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > What's the DateTime equivalent of null or empty? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|