473,566 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can someone explain this nullable datetime error to me


Using vs2008 c#

i have this code snipet note: SUBMITTED_DT = DateTime? type

if ((DateTime.Now - billingEvent.SU BMITTED_DT).Day s 180)
{
throw new
BusinessExcepti on(Messages.Bil lingEvent_Save_ TooOld);
}
this causes an error on build saying .Days is not supported, and
asking if i am missing an assembly reference.
if i change the code to (ie add SUBMITTED_DT.Va lue)

if ((DateTime.Now - billingEvent.SU BMITTED_DT.Valu e).Days 180)
{
throw new
BusinessExcepti on(Messages.Bil lingEvent_Save_ TooOld);
}

then this builds ok, i know its something to do with using DateTime?
but i dont realy understand why.

Can anyone give me a Captain Dummy explanation of why .Value is
required ?
thanks

Peter
Oct 24 '08 #1
2 1317
On Thu, 23 Oct 2008 22:14:43 -0700, <Petedwrote:
I see. Ok thanks for that, that makes sense
I'm glad it makes sense to you. Reading it again, I'm not sure it makes
sense to me. The word "nullable" shows up so often, the whole thing seems
a bit like a blur to me. :)

But, if you're happy...I'm happy. :)
Oct 24 '08 #2

I thought that explanation was fine, actually, it does make sense to
me

thanks

Peter
>On Thu, 23 Oct 2008 22:14:43 -0700, <Petedwrote:
>I see. Ok thanks for that, that makes sense

I'm glad it makes sense to you. Reading it again, I'm not sure it makes
sense to me. The word "nullable" shows up so often, the whole thing seems
a bit like a blur to me. :)

But, if you're happy...I'm happy. :)
Oct 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5950
by: ESPNSTI | last post by:
Hi, Please don't shoot me if the answer is simple, I'm new to .Net and C# :) .. I'm attempting to convert a nullable type to it's "non-nullable" type in a generic way (without knowing what specific type the nullable type is.) The reason I'm trying this is because when I attempt to pass a nullable type value to a SqlCommand parameter and...
0
4158
by: pranesh.nayak | last post by:
Hello Group, (tech: C#, VS2005) I'm facing a problem in passing Nullable<DateTimeto a webservice. Below is code in webservice wrapper (reference.cs) used set/get date. When i set date value WS.PropertyDateTime = DateTime.Now();
5
51578
by: GG | last post by:
I am trying to add a nullable datetime column to a datatable fails. I am getting exception DataSet does not support System.Nullable<>. None of these works dtSearchFromData.Columns.Add( new DataColumn( "StartDate", typeof( DateTime? ) ) ); dtSearchFromData.Columns.Add( new DataColumn( "EndDate", typeof( System.Nullable<DateTime>) ) ); Any...
15
17842
by: scparker | last post by:
I have yet to find a satisfactory solution to this problem. It involves VB.NET 2.0 and datetime issues. I have a form that asks for a Date to be submitted in dd/mm/yyyy format. When this is submitted it then is then dealt with as follows: ------------------------------------ Public Sub Update(ByVal sender As Object, ByVal e As...
5
2944
by: =?Utf-8?B?emlubw==?= | last post by:
in .net 2.0, the class (myClass) contains a property defined as: private _creationDate as As Nullable(Of DateTime) Public Property CreationDate() As Nullable(Of DateTime) Get If _creationDate.HasValue Then Return _creationDate Else Return Nothing End If End Get
2
4232
by: Benton | last post by:
Hi there, I'm creating a custom server control, inheriting from TextBox. It has this AsDateTime property that returns the textbox contents converted to the nullable DateTime data type, as follows: public class TextBoxWeb : System.Web.UI.WebControls.TextBox {
6
3527
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have a generic function I am using to check constraints, an example of which is the following: Public Function ValidateMinValue(Of t As IComparable)(ByVal PropertyName As String, ByVal value As t, ByVal min As t) As Boolean Dim newMessage As String = String.Empty If value.CompareTo(min) < 0 Then newMessage = String.Format("{0} must not...
3
1935
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a start and end date in my application. If a user does not know their dates yet, I want them, they will be null in the DB and I want them to be blank in the application. So, I'm trying to figure out how to use a nullable date, and want to return it in my method. I tried to cast the output parameter, but I get a run-time cast error:...
2
7920
by: Andrus | last post by:
My type contains constructor with nullable parameter like public class Iandmed { public Iandmed(DateTime? miskuup) {} } I tried to get its constructor parameter type name using Type t = typeof(Iandmed); ConstructorInfo c = t.GetConstructors();
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.