nemolorn Posted May 29, 2012 Share Posted May 29, 2012 ///////////////////////////////// // 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; Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted May 29, 2012 Share Posted May 29, 2012 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. Quote Link to comment Share on other sites More sharing options...
FHannes Posted May 29, 2012 Share Posted May 29, 2012 That method doesn't work with my localized format as Bixby mentioned. How about this? [scar]var Str: string; begin DateTimeToString(Str, 'mmmm, dd', Now); WriteLn(Str); end.[/scar] Quote Link to comment Share on other sites More sharing options...
nemolorn Posted May 29, 2012 Author Share Posted May 29, 2012 Since less is usually more, Freddy's works Best. But now I also understand how a Case statement works, which will certainly help me out as well Quote Link to comment Share on other sites More sharing options...