Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

date format 'yymmdd' problem

Posted on 2004-03-23
7
Medium Priority
?
415 Views
Last Modified: 2010-04-05
I have a date format of yymmdd, when I WriteIn my yymmdd into my output file, it is suppose to be 040324. Why does it only appears 40324?

I'm using myDate.Text := FormatDateTime('yymmdd', Date);
StrToInt(myDate.Text);

How can I make it to appear as 040324?
0
Comment
Question by:cybermilky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 10665111
because as string is '040324'
but as Integer is   40324
emil
0
 
LVL 17

Accepted Solution

by:
mokule earned 200 total points
ID: 10665129
Hi
where it appears 40324 in myDate.Text ??
or after convertion StrToInt. When You converted string to integer You.ve got integer 40324.
You can convert such an integer two 6 digit string by
Edit1.Text := FormatDateTime('yymmdd',Now);
Edit2.Text := Format('%6.6d',[StrToInt(FormatDateTime('yymmdd',Now))]);
0
 
LVL 3

Expert Comment

by:JDuncan
ID: 10668799
You can write string type using writln as well as int so you do not need to do the strtoint conversion
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:cybermilky
ID: 10674105
Hi mokule,

It works!!!
It's like this... i have a TEdit to get the 040324 in my variable 'myDate'. Then,
SendDate := StrToInt(myDate.Text);
Writeln(F,Format('%-8.6d',[SendDate{strtoint(myDate.Text)}]));

What does %8.6d stands for?
0
 
LVL 17

Expert Comment

by:mokule
ID: 10675040
function Format converts data contained in [] to a string.
Here we converts only an integer SendDate.
%-8.6d is a format string informing how to convert
d - decimal convertion
8 - width - string will have 8 characters
6 - precision - string must have 6 digits (the resulting string is left-padded with zeros)
-  - left justification
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 10675190
I think it is very strange to make double conversion:
1. SendDate := StrToInt(myDate.Text);
2. Writeln(F,Format('%-8.6d',[SendDate]));
Isn't it more easy by one step:
Writeln(F, myDate.Text);
because myDate.Text is in right format (for example '040324')

emil
0
 
LVL 17

Expert Comment

by:mokule
ID: 10675413
You're absolutly right esoftbg.
As for me I presume that cybermilky has some reason to convert it to integer first.
Doing something between this convertions or I don't know what.
Mind that he don't use any separators in date format like he want to be an integer.
cybermilky must judge whether there is any sensible reason to convert it to integer.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question