473,410 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Dates As Function Parameters - Why so Convoluted?

I'm working with a Repeater using a custom function inside the
<itemtemplate> to return a text string. The parameters SHOULD be (DateTime,
DateTime, Int16) but the difficulties in getting DateTimes to be evaulated
is odd. It's much easier to do (String, String, Int16) and convert the
Strings back and forth to dates to compare. I'm also expecting that the 2nd
DateTime parameter will be "null" at times and want to detect that.

[Question]
I'm just curious why the DateTime datatype is much more convoluted in it's
use.

To get the parameters to work at all, I had to use
(DateTime.Parse(Databinder...).ToString()) - why couldn't I just use the
(datetime) Databinder...? I'm just getting into DateTime datatypes too, so
maybe it's just expereince I need.


Nov 18 '05 #1
6 1182
Jordan wrote:
I'm working with a Repeater using a custom function inside the
<itemtemplate> to return a text string. The parameters SHOULD be (DateTime,
DateTime, Int16) but the difficulties in getting DateTimes to be evaulated
is odd. It's much easier to do (String, String, Int16) and convert the
Strings back and forth to dates to compare. I'm also expecting that the 2nd
DateTime parameter will be "null" at times and want to detect that.

[Question]
I'm just curious why the DateTime datatype is much more convoluted in it's
use.

To get the parameters to work at all, I had to use
(DateTime.Parse(Databinder...).ToString()) - why couldn't I just use the
(datetime) Databinder...? I'm just getting into DateTime datatypes too, so
maybe it's just expereince I need.

Well, it really is a more complex type. Meaning doing a simple cast
from a string to an int is pretty simplistic, either it's numeric or not
and the conversion happens. Wherease dates are very localized and need
alot of validation based on the current locale, delimiters used, etc. I
think it's just to get this point across, it's not as simple as
converting a string to an int.

--
Craig Deelsnyder
Microsoft MVP - ASP.NET
Nov 18 '05 #2
> Well, it really is a more complex type. Meaning doing a simple cast
from a string to an int is pretty simplistic, either it's numeric or not
and the conversion happens. Wherease dates are very localized and need
alot of validation based on the current locale, delimiters used, etc. I
think it's just to get this point across, it's not as simple as
converting a string to an int.


That's understandable, but why doesn't the DateTime have a operator
for NULL comparison? I guess that's my real concern. Applying the same
understanding of nulls and matching them to dates... I don't see why it
would
be different than a NULL string. NULL is undeterministic regardless of it's
assumed datatype. A NULL date should equal a NULL string.

j
Nov 18 '05 #3
"Jordan" <jf*****@learn.colostate.edu> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Well, it really is a more complex type. Meaning doing a simple cast
from a string to an int is pretty simplistic, either it's numeric or not
and the conversion happens. Wherease dates are very localized and need
alot of validation based on the current locale, delimiters used, etc. I
think it's just to get this point across, it's not as simple as
converting a string to an int.
That's understandable, but why doesn't the DateTime have a operator
for NULL comparison? I guess that's my real concern. Applying the same
understanding of nulls and matching them to dates... I don't see why it
would
be different than a NULL string. NULL is undeterministic regardless of

it's assumed datatype. A NULL date should equal a NULL string.


Are you referring to NULL as a database concept? If you are, be aware that
normal types don't deal with NULL. Instead, a NULL value is represented as
an object of type DBNull.

--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #4
> Are you referring to NULL as a database concept? If you are, be aware that
normal types don't deal with NULL. Instead, a NULL value is represented as
an object of type DBNull.


That depends. The actual value is coming from a Sproc and so yes, the object
type
could be a DBNull...but that doesn't "help" me understand why
getting/evaulating a DBNull
into a String datatype is any different than getting/evaulating a DBNull
into a DateTime
datatype.

If I expected a NULL value, then I would certainly use the DBNull structure,
but I don't
know what I'm getting except that it's either a Date or a NULL.

j

Nov 18 '05 #5
"Jordan" <jf*****@learn.colostate.edu> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Are you referring to NULL as a database concept? If you are, be aware that normal types don't deal with NULL. Instead, a NULL value is represented as an object of type DBNull.
That depends. The actual value is coming from a Sproc and so yes, the

object type
could be a DBNull...but that doesn't "help" me understand why
getting/evaulating a DBNull
into a String datatype is any different than getting/evaulating a DBNull
into a DateTime
datatype.

If I expected a NULL value, then I would certainly use the DBNull structure, but I don't
know what I'm getting except that it's either a Date or a NULL.


Take a look at Convert.IsDBNull. It should work for many types.

BTW, what language are you using? I would guess VB.NET with Option Strict
Off, so that it's letting you get away with murder (i.e., without
understanding what's going on).
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #6
> Take a look at Convert.IsDBNull. It should work for many types.

BTW, what language are you using? I would guess VB.NET with Option Strict
Off, so that it's letting you get away with murder (i.e., without
understanding what's going on).


Cool, will do. I've used Convert before, but not for IsDBNull yet.

I'm using C# via ASP.NET. Explicit is on by default, but I'm not certiain
if that's the same as Option Strict for VB.NET (unless you mean Explicit too
or
MS changed it?)

j
Nov 18 '05 #7

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

Similar topics

1
by: Peter Bailey | last post by:
I have a student table with studentid as pk and an enrolment date field as date. I have made a qry to group on date and count the number of enrolments for a particular day. What this doesnt...
1
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from...
27
by: Marlene Stebbins | last post by:
I am experimenting with function pointers. Unfortunately, my C book has nothing on function pointers as function parameters. I want to pass a pointer to ff() to f() with the result that f() prints...
2
by: Child | last post by:
I am trying to insert some data into a table and keep gettting the error: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. Its me testing the database so...
5
by: DW | last post by:
I have a query in Access 2003 that has the following criteria SELECT tblOrder.SessionDate, tblMenus.Item_Name, tblOrder.Type, Format$(tblorder!SessionDate,"Short Time") AS SessionTime,...
2
by: serge | last post by:
/* Subject: How best to use BETWEEN Begin and End Dates to find out if an employee was/is member of any group for a certain date range? You can copy/paste this whole post in SQL Query Analyzer...
1
by: Blue Lagoon Products - Customer Services | last post by:
Hi, I am in a bit of a pickle...I need to know the Total figure of the gross field in my table between 2 dates specified in a query. I need to know what criteria to put into my query on the...
3
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...
7
by: mantrid | last post by:
Im reading a csv file with php and getting a date in the form 30/09/07 Which I am trying to insert into a mysql table which has the field formatted as yyyy-mm-dd hh:mm:ss I cant get it to insert...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.