Shortdate shows Day of Week

I use d.AbbreviatedDate to print the date to a report.
TurboReport1.writeTextMM(d.AbbreviatedDate, RGB(0,0,0), 16, “Arial”, “center”, true, false, false) ’ bold, not underlined, not italic

On Mac it prints as I would expect.

On Windows it adds the abbreviated day of the week in front of the regular Month day, year.

I don’t want it to print the day of the week but I can’t figure out why it’s doing that or how to stop it.
Is this a bug?

Look in your international settings. We get this format from the OS.

[quote=132676:@Tim Turner]On Windows it adds the abbreviated day of the week in front of the regular Month day, year.

I don’t want it to print the day of the week but I can’t figure out why it’s doing that or how to stop it.[/quote]

Function stripDay(s as string) As string s = replaceall(s,"Sun, ","") s = replaceall(s,"Mon, ","") s = replaceall(s,"Tue, ","") s = replaceall(s,"Wed, ","") s = replaceall(s,"Thu, ","") s = replaceall(s,"Fri, ","") s = replaceall(s,"Sat, ","") return s End Function

Valid only if the user settings are English. Needs to be completed for other languages. The alternative is to create a method that builds the abbreviated date from d.day, d.month, d.year.

If his short date includes the day of week, you cannot guarantee that it will be a 3. Letter code, nor what language it will be in. This is a User preference which can literally set up to be anything.

Actually, I am looking at Windows default user preferences, and Xojo’s date.AbbreviatedDate is yet another concept. Windows short date does not have the day of the week at all. And long date has the full day name, not the three characters one. But indeed the format can be customized to anything, including the three characters day.

My personal preference would go into building the appropriate string from the date properties. It is easy.

I want the date to look like: October 1, 2014

d.day returns 1 or 01
d.month returns 10

AbbreviatedDate is really close I just don’t understand why it is printing the day of the week.
I guess it is a windows setting in control panel.

AbbreviatedDate is described well in the LR. On Windows 7, the “AbbreviatedDate” result is showing text “Thu, Oct 02, 2014” for the “Region and Language - Format” setting (accessible from Windows “Control Panel”) for “Long date” = “dddd, MMMM dd, yyyy”.

[quote=132846:@Tim Turner]I want the date to look like: October 1, 2014

d.day returns 1 or 01
d.month returns 10

AbbreviatedDate is really close I just don’t understand why it is printing the day of the week.
I guess it is a windows setting in control panel.[/quote]

Use an 11 slos string array for the months names sucha as monthArray(0)= “Jan” then fetch them like

month = monthArray(d.month-1) Mydate = month+" "+str(d.day)+", "+str(d.year)

When I want a date in the format I wish, I use :

dim d as new date
dim datestring as string = d.month+" “+d.day+”, "+d.year

[quote=132901:@Lee Badham]When I want a date in the format I wish, I use :

dim d as new date
dim datestring as string = d.month+" “+d.day+”, "+d.year[/quote]

And how often have you seriously used that code ?

:wink: :wink: :wink:

More important… WHEN have you ever used it that it WORKED… since it won’t

TYPE MISMATCH : datestring is a STRING, while the elements of date are INTEGERS

perhaps

dim d as new date
dim datestring as string = str(d.month)+" "+str(d.day)+", "+str(d.year)

but I won’t mention the non-standard date even that produces…

Dave,
your code there st(d.month) prints 1 for January instead of what I want… which is “January”.

I can’t believe I have to write a lookup to translate the number to the month spelled out simply because the long date includes the day of the week. I guess I could split on , and remove the day of the week from the Long date returned and reform it into the string I want.

-Tim

Change your long date in the regional settings to remove the day.

Second last link on http://great-white-software.com/Great_White_Software/REALbasic_Code.html
A project with two methods for figuring out (in pure RB) the local day and month abbreviated names
I think swedish or one of those scandanavian languages was the only one that didn’t work

[quote=239721:@Tim Turner]Dave, your code there st(d.month) prints 1 for January instead of what I want… which is “January”.
[/quote]
Never meant to infer that it did produce “January”, since it was a rebuttal to the code below, which doesn’t work at all.

[quote=132901:@Lee Badham]When I want a date in the format I wish, I use :
dim d as new date
dim datestring as string = d.month+" “+d.day+”, "+d.year[/quote]

not to mention it was well over a year old topic :smiley:

Yes Dave I realize I posted a year later… just did a search on this and found my old thread on it because I was revisiting this code and it was not working the way I wanted. I know you well enough to know you are an excellent programmer. No slight intended! More of a “how do I do this” response that was not well written.

This would work on my computer but what about every Mac that doesn’t do that? I don’t want another common suport question “How do I get rid of the day of the week on the cover of this report”? I’d rather code it so that it just prints the date like: January 7, 2016

I did a split on the “,” in the return from d.Longdate and then reformatted it. But now I wonder if that won’t work. If someone changes their regional settings per Wayne, then it won’t return the Day? and then my code will display just the year most likely. Is there a way to code the date so that it is not affected by what the regional settings are???

If you want a solution independent of the computer locale, I am afraid the 12 slots solution or nthField on a constant is the only game in town.

It is really not that difficult to come up with a simple method that generates exactly the format you want from date.year, date.month, and date.day.

Thanks but for some reason that .rb file won’t open in my version of the software.

OK got it. I will use the month digit to do a lookup into an array of month names, or something like that. That way it will print what I want regardless of regional settings. THANKS EVERYONE!

Change the extension to .rbp or .xojo_binary_project