Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Date Type Modification Posted by sarkiemarkie on 4 Dec 2005 at 4:31 AM
I used Date Type for my date fields:

...

DateOfBirth:TdateTime;

...

BUT you have to write month/date/year or else an error message appears;

How can i change it to date/month/year?
Report
Re: Date Type Modification Posted by zibadian on 4 Dec 2005 at 5:48 AM
: I used Date Type for my date fields:
:
: ...
:
: DateOfBirth:TdateTime;
:
: ...
:
: BUT you have to write month/date/year or else an error message appears;
:
: How can i change it to date/month/year?
:
You can create your own date string parser, which gives you 3 integer variable. It's not that difficult. Then you can use EncodeDate() to fill the TDateTime variable with the integer values.
Report
Re: Date Type Modification Posted by sarkiemarkie on 4 Dec 2005 at 12:49 PM
: : I used Date Type for my date fields:
: :
: : ...
: :
: : DateOfBirth:TdateTime;
: :
: : ...
: :
: : BUT you have to write month/date/year or else an error message appears;
: :
: : How can i change it to date/month/year?
: :
: You can create your own date string parser, which gives you 3 integer variable. It's not that difficult. Then you can use EncodeDate() to fill the TDateTime variable with the integer values.
:

Can you tell me exactly how to do it. I have no idea

Report
Re: Date Type Modification Posted by zibadian on 4 Dec 2005 at 3:01 PM
: : : I used Date Type for my date fields:
: : :
: : : ...
: : :
: : : DateOfBirth:TdateTime;
: : :
: : : ...
: : :
: : : BUT you have to write month/date/year or else an error message appears;
: : :
: : : How can i change it to date/month/year?
: : :
: : You can create your own date string parser, which gives you 3 integer variable. It's not that difficult. Then you can use EncodeDate() to fill the TDateTime variable with the integer values.
: :
:
: Can you tell me exactly how to do it. I have no idea
:
:
If each of the number is always 2 digits long then this code should work:
  Day := StrToInt(DateStr[1]+DateStr[2]);
  Month := StrToInt(DateStr[4]+DateStr[5]);
  Year := StrToInt(DateStr[7]+DateStr[8]);
  Date := EncodeDate(Year, Month, Day);

If there is variation in the formatting (like 4 digits per year, or 1 per day/month) then you'll need to design a better parser.
Report
Re: Date Type Modification Posted by sarkiemarkie on 5 Dec 2005 at 11:56 AM
: : : : I used Date Type for my date fields:
: : : :
: : : : ...
: : : :
: : : : DateOfBirth:TdateTime;
: : : :
: : : : ...
: : : :
: : : : BUT you have to write month/date/year or else an error message appears;
: : : :
: : : : How can i change it to date/month/year?
: : : :
: : : You can create your own date string parser, which gives you 3 integer variable. It's not that difficult. Then you can use EncodeDate() to fill the TDateTime variable with the integer values.
: : :
: :
: : Can you tell me exactly how to do it. I have no idea
: :
: :
: If each of the number is always 2 digits long then this code should work:
:
:   Day := StrToInt(DateStr[1]+DateStr[2]);
:   Month := StrToInt(DateStr[4]+DateStr[5]);
:   Year := StrToInt(DateStr[7]+DateStr[8]);
:   Date := EncodeDate(Year, Month, Day);
: 

: If there is variation in the formatting (like 4 digits per year, or 1 per day/month) then you'll need to design a better parser.
:
where would i insert that code. parser is a completely new word for me
Report
Re: Date Type Modification Posted by zibadian on 5 Dec 2005 at 1:12 PM
: : : : : I used Date Type for my date fields:
: : : : :
: : : : : ...
: : : : :
: : : : : DateOfBirth:TdateTime;
: : : : :
: : : : : ...
: : : : :
: : : : : BUT you have to write month/date/year or else an error message appears;
: : : : :
: : : : : How can i change it to date/month/year?
: : : : :
: : : : You can create your own date string parser, which gives you 3 integer variable. It's not that difficult. Then you can use EncodeDate() to fill the TDateTime variable with the integer values.
: : : :
: : :
: : : Can you tell me exactly how to do it. I have no idea
: : :
: : :
: : If each of the number is always 2 digits long then this code should work:
: :
: :   Day := StrToInt(DateStr[1]+DateStr[2]);
: :   Month := StrToInt(DateStr[4]+DateStr[5]);
: :   Year := StrToInt(DateStr[7]+DateStr[8]);
: :   Date := EncodeDate(Year, Month, Day);
: : 

: : If there is variation in the formatting (like 4 digits per year, or 1 per day/month) then you'll need to design a better parser.
: :
: where would i insert that code. parser is a completely new word for me
:
A parser is a code or an object, which reads some data and can determine what it says. In this case the code I gave you here is a very simple parser which reads the variable DateStr and can convert it into an actual date in the memory.
The Delphi compiler uses a parser object to read your source code and make sense of it, so that the compiler can change it into binary code.
Report
Re: Date Type Modification Posted by sarkiemarkie on 11 Feb 2006 at 5:12 AM
: : : : : : I used Date Type for my date fields:
: : : : : :
: : : : : : ...
: : : : : :
: : : : : : DateOfBirth:TdateTime;
: : : : : :
: : : : : : ...
: : : : : :
: : : : : : BUT you have to write month/date/year or else an error message appears;
: : : : : :
: : : : : : How can i change it to date/month/year?
: : : : : :
: : : : : You can create your own date string parser, which gives you 3 integer variable. It's not that difficult. Then you can use EncodeDate() to fill the TDateTime variable with the integer values.
: : : : :
: : : :
: : : : Can you tell me exactly how to do it. I have no idea
: : : :
: : : :
: : : If each of the number is always 2 digits long then this code should work:
: : :
: : :   Day := StrToInt(DateStr[1]+DateStr[2]);
: : :   Month := StrToInt(DateStr[4]+DateStr[5]);
: : :   Year := StrToInt(DateStr[7]+DateStr[8]);
: : :   Date := EncodeDate(Year, Month, Day);
: : : 

: : : If there is variation in the formatting (like 4 digits per year, or 1 per day/month) then you'll need to design a better parser.
: : :
: : where would i insert that code. parser is a completely new word for me
: :
: A parser is a code or an object, which reads some data and can determine what it says. In this case the code I gave you here is a very simple parser which reads the variable DateStr and can convert it into an actual date in the memory.
: The Delphi compiler uses a parser object to read your source code and make sense of it, so that the compiler can change it into binary code.
:
there is actally a built in functon that i found.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.