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

Birthday generated by ID number

Hi

I want to split a IDNumber to determine the date of birth.Something
like this.

DateTime dtBirth

split txtIdNumber in yy mm dd
Assume the idnumber = 8210195017089

dtBirth.NewDate(82, 10, 19)

txtBirthdate.text = dtBirth

Can anyone help me please

Thanks in Advance

Dec 14 '05 #1
8 11838
Hello

you can do something like this

string s = "8210195017089";
MessageBox.Show( s.Substring(0,6));

or

long ln = 8210195017089;
MessageBox.Show(ln.ToString().Substring(0,6));
Regards
Karthik K
"Wolf" <ja********@citadel.co.za> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi

I want to split a IDNumber to determine the date of birth.Something
like this.

DateTime dtBirth

split txtIdNumber in yy mm dd
Assume the idnumber = 8210195017089

dtBirth.NewDate(82, 10, 19)

txtBirthdate.text = dtBirth

Can anyone help me please

Thanks in Advance

Dec 14 '05 #2
This is bad design. You should be using two seperate columns (im assuming
this is how IDNumber is stored in the db).

--

Derek Davis
dd******@gmail.com

"Wolf" <ja********@citadel.co.za> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi

I want to split a IDNumber to determine the date of birth.Something
like this.

DateTime dtBirth

split txtIdNumber in yy mm dd
Assume the idnumber = 8210195017089

dtBirth.NewDate(82, 10, 19)

txtBirthdate.text = dtBirth

Can anyone help me please

Thanks in Advance

Dec 15 '05 #3
I wouldn't be pouncing on the fact that it is a bad design without
knowing the whole reason for it existing in the first place.
I think we should just try to answer the main question here. The
following code is similar to what Karthik was saying:

long ID = 8210195017089;

int year = Convert.ToInt32(ID.ToString(0, 2));
int month = Convert.ToInt32(ID.ToString(2, 2));
int day = Convert.ToInt32(ID.ToString(4, 2));

DateTime dob = new DateTime(year, month, day);

txtBirthdate.Text = dob.ToLongDateString();

Steven Nagy

Dec 15 '05 #4
Thank you guys for youre help.I got it right in the meantime.
This was my solution and thanks for confirming it to me

string strIDnumber = txtIDNumber.Text;
int intYear = Convert.ToInt32("19" + strIDnumber.Substring(0,2));
int intMonth = Convert.ToInt32(strIDnumber.Substring(2,2));
int intDay = Convert.ToInt32(strIDnumber.Substring(4,2));
DateTime dtBirthDateFromID = new DateTime(intYear, intMonth,
intDay);
dtBirthDate.Date = dtBirthDateFromID;

Dec 15 '05 #5
This topic would get a tad bit diff response in a more db specific NG. Ask
Joe Celko his opinion on the subject.

http://www.webopedia.com/TERM/K/kludge.html ;)

--

Derek Davis
dd******@gmail.com

"Steven Nagy" <le*********@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I wouldn't be pouncing on the fact that it is a bad design without
knowing the whole reason for it existing in the first place.
I think we should just try to answer the main question here. The
following code is similar to what Karthik was saying:

long ID = 8210195017089;

int year = Convert.ToInt32(ID.ToString(0, 2));
int month = Convert.ToInt32(ID.ToString(2, 2));
int day = Convert.ToInt32(ID.ToString(4, 2));

DateTime dob = new DateTime(year, month, day);

txtBirthdate.Text = dob.ToLongDateString();

Steven Nagy

Dec 16 '05 #6
I don't really see how a DB NG is relevant personally. It was a C#
coding question about how to convert an int into a date time.

The why of it is really up to the programmer. I mean, I totally agree
with you about the DB key thing... I personally would use an identity
and have the dob in a different field.
But thats not really what the person was asking. In fact, in their
initial question there was no mention of a database at all.
And even it there was, perhaps the person doesn't have a choice because
its a legacy application and that's how the data is stored.
In fact, perhaps the context is that they were trying to UPDATE the
database and move the IDnumbers into the date of birth column!
We just don't know, so I personally think we should spend more of our
efforts trying to answer the persons question, rather than restructure
their way of thinking.

Its all good. We all are eternally bound together by our decision to
use C# and that makes us all comrades to the end!

Dec 16 '05 #7
> I don't really see how a DB NG is relevant personally. It was a C#
coding question about how to convert an int into a date time.
Yes, the OP asked a c# question but the real issue could be in the db. So
many coders have just enough db knowledge to be dangerous!
And even it there was, perhaps the person doesn't have a choice because
its a legacy application and that's how the data is stored.
In fact, perhaps the context is that they were trying to UPDATE the
database and move the IDnumbers into the date of birth column!
We just don't know, so I personally think we should spend more of our
efforts trying to answer the persons question, rather than restructure
their way of thinking.


I suspect the OP is relatively in-experienced. As you stated, there are
many aspects of the OP's situation that we don't know. If I my assumptions
and suspicions are correct, wouldn't you agree that it is better to correct
his implementation now rather than later? What if the OP was/is still in
the early stages of implementation and simply didn't/doesn't know any
better?

***OP please note that this post is not meant to be derogatory in any way.
If I completely missed the mark, I do apologize.***

--

Derek Davis
dd******@gmail.com
Dec 16 '05 #8
I completely understand where you are coming from in terms of "catching
the problem in its early stages".
But if the OP is indeed inexperienced to the point where they are
creating ID fields in a DB that is a construct of a DOB, then I would
also guess that its not a huge project.
If it IS, then they are going to be caught out anyway with other DB
programming problems and the DOB-ID will be the least of their worries.

Its not unusual to see this kind of DB structure in older applications.

However my guess as to the OP's position is that they are a student
trying to solve some problem or assignment.
Perhaps its even a MCP exam question!

No offense taken here. I just know what its like to ask a question, and
have people try anticipate why I'm doing something as opposed to
actually answering the question.
Usually its so left field its impossible to describe anyway!

Steven Nagy

Dec 16 '05 #9

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

Similar topics

51
by: Sandra | last post by:
I was given this problem for extra credit and I am just stuck ! BTW - I am not asking for source code and I am not asking anyone to do my homework as I do want to learn .. I just need a hint or two...
1
by: Claude Alain | last post by:
Hello! We are a small non-profit organisation with about 400 members. We have created a database using Access97 which contains tombstone information on our members, including home adresses and...
2
by: edwin van rutten | last post by:
Hi I have a personal database of all adresses etceteras of personal contacts and want to sort the birthday dates in such a way that I have a chronological list for this years birthdays. The...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
2
by: David Garamond | last post by:
What would be the more proper way of storing birthday data? It will be used to send out birthday messages for customers ("Happy 30th birthday, Sam!"). But the date of birth is not necessarily known...
5
by: NomoreSpam4Me | last post by:
Hi, i did a search and find the way to get the birthday without the year. My field is yyyy/mm/dd, (birthday). I also have a day field (1 to 31) and a month field. (1 to 12) My problem is: I...
13
kestrel
by: kestrel | last post by:
Sheila and He-Man are twins; Sheila is the OLDER twin. Assume they were born immediately after each other, an infinitesimally small - but nonzero - amount of time apart. During one year in the...
1
by: TWX | last post by:
Hi there. I need to create a PHP programme that will return a person's birthday when his class and index number is keyed. I have the neccesary information but I only know how to create the frame of...
1
by: stilldancin12 | last post by:
Ok so i have to write an application that asks for the users birthday and replies with they day of the week in which he or she is born on, using the java program. This is what I have so far.It gives...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.