Jump to content
nemolorn

Month and Day

Recommended Posts

/////////////////////////////////
//  Procedure EchoDate Returns //
//  Date Based on System Time  //
//  Created by                 //
//  Nemolorn 5/29/2012         //
/////////////////////////////////
Procedure EchoDate;
Var
xmon,xday,xname : string;
begin
 WriteLn(DateToStr(Date)); 
 IF Left(DateToStr(Date), 2) = '1/' = True Then
   xmon := 'January';  
 Else IF Left(DateToStr(Date), 2) = '2/' = True Then
   xmon := 'February';
 Else IF Left(DateToStr(Date), 2) = '3/' = True Then
   xmon := 'March';
 Else IF Left(DateToStr(Date), 2) = '4/' = True Then
   xmon := 'April';
 Else IF Left(DateToStr(Date), 2) = '5/' = True Then
   xmon := 'May';
 Else IF Left(DateToStr(Date), 2) = '6/' = True Then
   xmon := 'June';
 Else IF Left(DateToStr(Date), 2) = '7/' = True Then
   xmon := 'July';
 Else IF Left(DateToStr(Date), 2) = '8/' = True Then
   xmon := 'August';
 Else IF Left(DateToStr(Date), 2) = '9/' = True Then
   xmon := 'September';
 Else IF Left(DateToStr(Date), 2) = '10' = True Then
   xmon := 'October';
 Else IF Left(DateToStr(Date), 2) = '11' = True Then
   xmon := 'November';
 Else IF Left(DateToStr(Date), 2) = '12' = True Then
   xmon := 'December';
   xDay := TrimOthers(right(Left(DatetoStr(Date),5),3));
   Xname := xmon + ', ' + xDay; 
   WriteLn(xname);
end;

Link to comment
Share on other sites

Have you considered using a case statement:

[sCAR]/////////////////////////////////

// Procedure EchoDate Returns //

// Date Based on System Time //

// Created by //

// Nemolorn 5/29/2012 //

/////////////////////////////////

Procedure EchoDate;

Var

xmon,xday,xname : string;

begin

WriteLn(DateToStr(Date));

case Left(DateToStr(Date), 2) of

'1/': xmon := 'January';

'2/': xmon := 'February';

'3/': xmon := 'March';

'4/': xmon := 'April';

'5/': xmon := 'May';

'6/': xmon := 'June';

'7/': xmon := 'July';

'8/': xmon := 'August';

'9/': xmon := 'September';

'10': xmon := 'October';

'11': xmon := 'November';

'12': xmon := 'December';

end;

xDay := TrimOthers(right(Left(DatetoStr(Date),5),3));

Xname := xmon + ', ' + xDay;

WriteLn(xname);

end;[/sCAR]

 

Coincidentally this is very dependent on your date format. I use yyyy-MM-dd as my system date format, which breaks this completely.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...