Solved

date format 'yymmdd' problem

Posted on 2004-03-23
7
384 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
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 50 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now