473,396 Members | 1,998 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,396 software developers and data experts.

Date ONLY data type.

Hi,

I'd like to be able to distinguish between a DateTime variable that is
allowed to hold both date and time and a DateTime variable that is allowed
to only hold a Date.
The reason's for this is that I'd like to store DateTime variables that are
allowed to hold date and time as UTC in the database.
However I'd to store DateTime variables that are only allowed to hold a date
(like a birthdate) not as UTC (since adding a +6h time offset to something
that didn't have a time specified in the first place isn't meaningful).
Unfortunately, I DO have scenarios where I have date and time combinations
where 00:00 is a valid entered time (otherwise I could have used that to
determine if it was a date only).

For example I'd like to be able to do something like this:

public static void AddParameter(ref SqlCommand aCommand, string aName,
DateTime aValue)
{
if (!aValue.ISDATEONLY) //<-- ISDATEONLY isn't a method that exists,
I'm looking for something like that.
// The value needs to be save in the database in UTC
aValue = aValue.ToUniversalTime();
AddParameter(ref aCommand, aName, aValue);
}

Now I figured I'd define a class something like this in order to indicate if
a variable is a date only ( I'm used to have something similar available in
Delphi ) :

public class Date : DateTime
{
}

However, DateTime is sealed. :(

Now I could do something like this:

public class Date
{
DateTime Value;
}

However, I'd like to be able to bind properties defined as Date to UI Date /
Time controls, so I'd like to keep working with DateTime. (Or is there an
easy way to bind something like the Date class above to a UI Date / Time
control?)

Ideas?

Thanks,
Erik
Nov 17 '05 #1
1 9812
Hi,

I think your solution is good, create a class with a member of DateTime
and a bool that indicate if it hold a Date only.

You could also add other members as needed.

You could use then MyDate.TheDateTime to bind to the datetimepick control
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"ESPNSTI" <ES*********@Hotmail.com> wrote in message
news:eE**************@TK2MSFTNGP09.phx.gbl...
Hi,

I'd like to be able to distinguish between a DateTime variable that is
allowed to hold both date and time and a DateTime variable that is allowed
to only hold a Date.
The reason's for this is that I'd like to store DateTime variables that
are
allowed to hold date and time as UTC in the database.
However I'd to store DateTime variables that are only allowed to hold a
date
(like a birthdate) not as UTC (since adding a +6h time offset to something
that didn't have a time specified in the first place isn't meaningful).
Unfortunately, I DO have scenarios where I have date and time combinations
where 00:00 is a valid entered time (otherwise I could have used that to
determine if it was a date only).

For example I'd like to be able to do something like this:

public static void AddParameter(ref SqlCommand aCommand, string aName,
DateTime aValue)
{
if (!aValue.ISDATEONLY) //<-- ISDATEONLY isn't a method that
exists,
I'm looking for something like that.
// The value needs to be save in the database in UTC
aValue = aValue.ToUniversalTime();
AddParameter(ref aCommand, aName, aValue);
}

Now I figured I'd define a class something like this in order to indicate
if
a variable is a date only ( I'm used to have something similar available
in
Delphi ) :

public class Date : DateTime
{
}

However, DateTime is sealed. :(

Now I could do something like this:

public class Date
{
DateTime Value;
}

However, I'd like to be able to bind properties defined as Date to UI Date
/
Time controls, so I'd like to keep working with DateTime. (Or is there an
easy way to bind something like the Date class above to a UI Date / Time
control?)

Ideas?

Thanks,
Erik

Nov 17 '05 #2

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

Similar topics

1
by: Yong Wang | last post by:
> Hi: > We have a database system. In the database, we have an > attribute called date0, which contains date data (format: > i. e. 2004-08-12). I wrote a script to fetch the data > in a...
1
by: John Cosmas | last post by:
I've encountered a table that stores dates in Gregorian format so that the dates and time looks like straight integers that cannot be easily discrened as a date or time by just looking at it. I'm...
2
by: Douglas | last post by:
I have a Vehicle MOT field in my table which i have as a Date field I dont really want to hold the year, just 'dd mmm' as MOTs are the same date every year. I have the field on my form as a...
2
by: Remi Caron | last post by:
Hi, I took over an Visual Object project (Visual Clipper) in that language there is a function to: Convert a string containing a 32-bit binary date to a date data type. That function is called...
1
by: Alan | last post by:
Any data type that I can use to store date ?
1
by: glenn | last post by:
Hi folks, I am doing an UPDATE to a table that has a field for a DATE data type. I am using MS Access. The UPDATE works fine but when I try to place the DATE field in the mix it blows up. ...
3
by: glenn | last post by:
Hi folks, I have 2 code snippets. One works and one does not. This first hard-coded snippet works Dim queryString As String = "UPDATE SET = '8/16/2006' WHERE (. = @id)" This second...
4
by: loisk | last post by:
Hi, I need to compare a date (on a form )entered by a user with today's date and a date should not be greater than today. The problem, however, the data type for the date is string, not date date...
6
by: dkyadav80 | last post by:
Hi guys, I have a form in html , all description below: first: name of persion (input type box) second: job profile (input type box) third: experience from: list box (Month : Jan, Feb,.....
6
by: gozdeata | last post by:
hey there, i m trying to get only time information of a date type variable. i got a column in type of char, it keeps time info in hh:mm format - 5 characters when i tried to convert it to date...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.