473,231 Members | 1,399 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,231 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 11795
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...

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.