Solved

date format 'yymmdd' problem

Posted on 2004-03-23
7
392 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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