473,799 Members | 2,840 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(re f SqlCommand aCommand, string aName,
DateTime aValue)
{
if (!aValue.ISDATE ONLY) //<-- 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.ToUniver salTime();
AddParameter(re f 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 9834
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.TheDateT ime to bind to the datetimepick control
cheers,

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

"ESPNSTI" <ES*********@Ho tmail.com> wrote in message
news:eE******** ******@TK2MSFTN GP09.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(re f SqlCommand aCommand, string aName,
DateTime aValue)
{
if (!aValue.ISDATE ONLY) //<-- 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.ToUniver salTime();
AddParameter(re f 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
2628
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 specified time period: > for exaplme: > date1 = raw_input('start date ') > date2 = raw_input('end date ') > > ie. date1 = '2004-08-12'
1
1304
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 using SQL to query the table and retrieve the data as an integer. I'm tyring to figure out how to best CAST or CONVERT the field into a DATE type so that its readable in the right format. I'm coding in VB.NET and the use of CDATE and FORMAT have...
2
2431
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 listbox holding all the dates of the year, except 29 Feb which i dont need anyway. When i select a value from the list i.e. 14 May and it stores it in the table i believe it stores the current year as well i.e 14 May 2004 The problem now is how do i...
2
2875
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 bin2Date and there also is a Date2bin function of course in cannot find how to do this in csharp. The string looks like this "!$%\0" and should return 03/09/52 can somebody point me in the right direction? Have tried Convert class in several ways...
1
4353
by: Alan | last post by:
Any data type that I can use to store date ?
1
1947
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. The table name is rfi.
3
1980
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 snippet does not work
4
1712
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 type. Is there anyway that I can test the user-entered-date against today's date? Thanks!
6
2993
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,.. format) and experience to: list box (year: 2008,2007,2006,...) In Mysql database only 4 filed, 1. Name(data type - varchar),
6
11438
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 with to_date(, 'hh24:mi') it gives me a date starts with the ifrst day of current mount, year etc. 01/10/2008 14:04 for example. i need a solution to get time info in date data type from a char column in hh:mm thanx for ypur care...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10482
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10225
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9072
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5463
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
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
3
2938
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.