Discussion:
Help please: ParseDate in RB2007R1
Lennox Jacob
2007-02-11 21:43:28 UTC
Permalink
Hello,

I have an app that was built with RB2005R2 (MAC PowerPC), I used longdates a lot and when I saved my files the dates were saved in the format Tuesday, August 12, 1980.

When I opened my files I would use ParseDate to verify the date and I had no problems.

Now I have built my app in RB2007R1 and I am getting an error opening my files, apparently RB2007R1 is expecting the dates in the format Tuesday, 12 August 1980.

How do I get around that?

Thanks.

Lennox.



---------------------------------
Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
Russ Jones
2007-02-11 22:04:04 UTC
Permalink
Hi Lennox.

When you use the LongDate format, you get the date formatted
according to the settings of the user's computer OS, according to the
LR:

"Reports the date in the user’s long date format as a string
based on the user’s locale and formatting even if the
user’s locale is a Unicode-only locale. Example (US format):
Wednesday, December 31, 1997."

So, it seems to me, you should be prepared to accept as input any
valid formatting the user can select.

Russ

p.s. I think RB closing this list is really unfortunate.
Post by Lennox Jacob
Hello,
I have an app that was built with RB2005R2 (MAC PowerPC), I used
longdates a lot and when I saved my files the dates were saved in
the format Tuesday, August 12, 1980.
When I opened my files I would use ParseDate to verify the date and I had no problems.
Now I have built my app in RB2007R1 and I am getting an error
opening my files, apparently RB2007R1 is expecting the dates in the
format Tuesday, 12 August 1980.
How do I get around that?
Thanks.
Lennox.
Russ Jones
***@computer.org
RB 2007r1 MacOS 10.4.8
Norman Palardy
2007-02-11 22:05:50 UTC
Permalink
Post by Lennox Jacob
Hello,
I have an app that was built with RB2005R2 (MAC PowerPC), I used
longdates a lot and when I saved my files the dates were saved in
the format Tuesday, August 12, 1980.
When I opened my files I would use ParseDate to verify the date and I had no problems.
Now I have built my app in RB2007R1 and I am getting an error
opening my files, apparently RB2007R1 is expecting the dates in the
format Tuesday, 12 August 1980.
How do I get around that?
It dependent on how your long date settings are set in the OS
Not sure of the precise nature of the change from 2005 to 2007 but it
has to do with only using the OS supplied routines
You're not the first to bump into this change

If you change your long date settings in OS X you may be able to
affect this

The other would be to remove the last , from the dates you have when
you read them and then save them in a format that is much easier to
deal with regardless of any other changes that are made to textual
representations of dates and times (ie/ SQLDateTime format)

The other might be to save the totalseconds instead of the actual
date and then you can show it in whatever format you want
Lennox Jacob
2007-02-11 22:39:22 UTC
Permalink
Thanks Russ and Norman,

I need to explain a little more...

So I have a file that was saved previously, the date of birth was saved as a long date in RB2005 - Tuesday, August 12, 1980, apparently that format is not used again in RB2007R1.

"We have updated to using the new APIs apple
provided in 10.4. These APIs don't allow the same formats that
previously were used, and instead use the formats specified in the
International preferences pane. There are four styles: short, medium,
long, and full. For "Abbreviated" we use the "medium" style.

HTH,
Jon"
[input] [input] [input] [input]
So, I now use that date via Parse date to calculate the current age and since the parsdate format is changed it gives an error - RB2007R1 is expecting the longdate in the format Tuesday, 12 August 1980.

So, I use a text editor and manually change Tuesday, August 12, 1980 to Tuesday, 12 August 1980 and all is well. When I save and then reopen there is no problem because the formatting has already been corrected.

It means that I have to change the date of birth manually when I want to open any old file.

That is what I would like to get done, changing that old format to the new format, seemlessly, in the background.

Any advice or recommendations.

Thanks again.

Lennox.
Post by Lennox Jacob
Hello,
I have an app that was built with RB2005R2 (MAC PowerPC), I used
longdates a lot and when I saved my files the dates were saved in
the format Tuesday, August 12, 1980.
When I opened my files I would use ParseDate to verify the date and I had no problems.
Now I have built my app in RB2007R1 and I am getting an error
opening my files, apparently RB2007R1 is expecting the dates in the
format Tuesday, 12 August 1980.
How do I get around that?
It dependent on how your long date settings are set in the OS
Not sure of the precise nature of the change from 2005 to 2007 but it
has to do with only using the OS supplied routines
You're not the first to bump into this change

If you change your long date settings in OS X you may be able to
affect this

The other would be to remove the last , from the dates you have when
you read them and then save them in a format that is much easier to
deal with regardless of any other changes that are made to textual
representations of dates and times (ie/ SQLDateTime format)

The other might be to save the totalseconds instead of the actual
date and then you can show it in whatever format you want
_______________________________________________
Unsubscribe:


REAL Software has decided to consolidate this mailing list with the online Forums. On Monday, February 12, 2007, this mailing list will no longer be active. We encourage you to continue your REALbasic and REAL SQL Server discussions on the Forums. If you are not presently a member of the forum, please sign up today at .



---------------------------------
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
Russ Jones
2007-02-11 22:56:13 UTC
Permalink
If you can detect that you have an old file to deal with, you can use
the Split function to split the date using a comma to effect the split.
Then you can reconstitute the date, minus the weekday. Parsedate
should then be able to handle it.

Another similar solution is to use NthField.
Still, you have to lop off the weekday.

All the best.

Russ
Post by Lennox Jacob
Thanks Russ and Norman,
I need to explain a little more...
So I have a file that was saved previously, the date of birth was
saved as a long date in RB2005 - Tuesday, August 12, 1980,
apparently that format is not used again in RB2007R1.
"We have updated to using the new APIs apple
provided in 10.4. These APIs don't allow the same formats that
previously were used, and instead use the formats specified in the
International preferences pane. There are four styles: short, medium,
long, and full. For "Abbreviated" we use the "medium" style.
HTH,
Jon"
[input] [input] [input] [input]
So, I now use that date via Parse date to calculate the current age
and since the parsdate format is changed it gives an error -
RB2007R1 is expecting the longdate in the format Tuesday, 12 August
1980.
So, I use a text editor and manually change Tuesday, August 12,
1980 to Tuesday, 12 August 1980 and all is well. When I save and
then reopen there is no problem because the formatting has already
been corrected.
It means that I have to change the date of birth manually when I want to open any old file.
That is what I would like to get done, changing that old format to
the new format, seemlessly, in the background.
Any advice or recommendations.
Thanks again.
Lennox.
Post by Lennox Jacob
Hello,
I have an app that was built with RB2005R2 (MAC PowerPC), I used
longdates a lot and when I saved my files the dates were saved in
the format Tuesday, August 12, 1980.
When I opened my files I would use ParseDate to verify the date and I had no problems.
Now I have built my app in RB2007R1 and I am getting an error
opening my files, apparently RB2007R1 is expecting the dates in the
format Tuesday, 12 August 1980.
How do I get around that?
It dependent on how your long date settings are set in the OS
Not sure of the precise nature of the change from 2005 to 2007 but it
has to do with only using the OS supplied routines
You're not the first to bump into this change
If you change your long date settings in OS X you may be able to
affect this
The other would be to remove the last , from the dates you have when
you read them and then save them in a format that is much easier to
deal with regardless of any other changes that are made to textual
representations of dates and times (ie/ SQLDateTime format)
The other might be to save the totalseconds instead of the actual
date and then you can show it in whatever format you want
_______________________________________________
REAL Software has decided to consolidate this mailing list with the
online Forums. On Monday, February 12, 2007, this mailing list
will no longer be active. We encourage you to continue your
REALbasic and REAL SQL Server discussions on the Forums. If you
are not presently a member of the forum, please sign up today at .
---------------------------------
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
_______________________________________________
REAL Software has decided to consolidate this mailing list with the
online Forums. On Monday, February 12, 2007, this mailing list
will no longer be active. We encourage you to continue your
REALbasic and REAL SQL Server discussions on the Forums. If you
are not presently a member of the forum, please sign up today at
<http://forums.realsoftware.com>.
Russ Jones
***@computer.org
RB 2007r1 MacOS 10.4.8
Norman Palardy
2007-02-11 23:06:41 UTC
Permalink
Post by Lennox Jacob
Thanks Russ and Norman,
So, I use a text editor and manually change Tuesday, August 12,
1980 to Tuesday, 12 August 1980 and all is well. When I save and
then reopen there is no problem because the formatting has already
been corrected.
It means that I have to change the date of birth manually when I want to open any old file.
That is what I would like to get done, changing that old format to
the new format, seemlessly, in the background.
Any advice or recommendations.
If you read the "date" in a s a string see if it has 2 commas and if
it does you know it is the old format
Delete the second comma and away you go

something like

// assuming the date of interest is in dateStr already

select case countFields(dateStr,",")
case 2
// this date is already like Tuesday, 12 August 1980
case 3
// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string

weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)

dateStr = weekDay + ", " + month + " " + year

else
// something else
end select

// now use parse date on dateStr
Lennox Jacob
2007-02-12 04:04:47 UTC
Permalink
Thanks Norman,
But I have been trying this and many of my modifications of it

// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string

weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)

dateStr = weekDay + ", " + month + " " + year

to get from Tuesday, August 12, 1980 to Tuesday, 12 August 1980 or
12/08/1980, both of which are acceptable, but I was not able to do so.

Kindly assist.

Thanks.

Lennox.
Post by Lennox Jacob
Thanks Russ and Norman,
So, I use a text editor and manually change Tuesday, August 12,
1980 to Tuesday, 12 August 1980 and all is well. When I save and
then reopen there is no problem because the formatting has already
been corrected.
It means that I have to change the date of birth manually when I want to open any old file.
That is what I would like to get done, changing that old format to
the new format, seemlessly, in the background.
Any advice or recommendations.
If you read the "date" in a s a string see if it has 2 commas and if
it does you know it is the old format
Delete the second comma and away you go

something like

// assuming the date of interest is in dateStr already

select case countFields(dateStr,",")
case 2
// this date is already like Tuesday, 12 August 1980
case 3
// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string

weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)

dateStr = weekDay + ", " + month + " " + year

else
// something else
end select

// now use parse date on dateStr


_______________________________________________
Unsubscribe:


REAL Software has decided to consolidate this mailing list with the online Forums. On Monday, February 12, 2007, this mailing list will no longer be active. We encourage you to continue your REALbasic and REAL SQL Server discussions on the Forums. If you are not presently a member of the forum, please sign up today at .



---------------------------------
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
Louis G5 Batayte
2007-02-12 04:23:07 UTC
Permalink
In your example, the first is August 12 and the second is 12 August.
Therefore, you are going to reparse your month string into day and
mnth using a space as the separator, and then write those out in the
reverse order.

dateStr = weekDay + ", " + day + " " + mnth + " " + Year

Lou
Post by Lennox Jacob
Thanks Norman,
But I have been trying this and many of my modifications of it
// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string
weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)
dateStr = weekDay + ", " + month + " " + year
to get from Tuesday, August 12, 1980 to Tuesday, 12 August 1980 or
12/08/1980, both of which are acceptable, but I was not able to do so.
Kindly assist.
Thanks.
Lennox.
Post by Lennox Jacob
Thanks Russ and Norman,
So, I use a text editor and manually change Tuesday, August 12,
1980 to Tuesday, 12 August 1980 and all is well. When I save and
then reopen there is no problem because the formatting has already
been corrected.
It means that I have to change the date of birth manually when I
want to open any old file.
That is what I would like to get done, changing that old format to
the new format, seemlessly, in the background.
Any advice or recommendations.
If you read the "date" in a s a string see if it has 2 commas and if
it does you know it is the old format
Delete the second comma and away you go
something like
// assuming the date of interest is in dateStr already
select case countFields(dateStr,",")
case 2
// this date is already like Tuesday, 12 August 1980
case 3
// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string
weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)
dateStr = weekDay + ", " + month + " " + year
else
// something else
end select
// now use parse date on dateStr
_______________________________________________
REAL Software has decided to consolidate this mailing list with the
online Forums. On Monday, February 12, 2007, this mailing list
will no longer be active. We encourage you to continue your
REALbasic and REAL SQL Server discussions on the Forums. If you
are not presently a member of the forum, please sign up today at .
---------------------------------
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
_______________________________________________
REAL Software has decided to consolidate this mailing list with the
online Forums. On Monday, February 12, 2007, this mailing list
will no longer be active. We encourage you to continue your
REALbasic and REAL SQL Server discussions on the Forums. If you
are not presently a member of the forum, please sign up today at
<http://forums.realsoftware.com>.
Michael
2007-02-12 04:23:51 UTC
Permalink
Hi Lennox,
Not sure if this is relevant, but RB 07R1 has ( i think, changed the
valid strings). From LR:

"The Text parameter must be a valid String representation of a Date.
You can use the slash, the dash, the period, or the space to separate
the Month, Day, and Year. For example, the following are valid String
representations: 12/14/1341, 12-14-1341, 12.14.1341, 14Dec1341,
14.Dec.1341, and 14 Dec. 1341. "

Are you sure your string matches one of those above.

Michael.
Post by Lennox Jacob
Thanks Norman,
But I have been trying this and many of my modifications of it
// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string
weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)
dateStr = weekDay + ", " + month + " " + year
to get from Tuesday, August 12, 1980 to Tuesday, 12 August 1980 or
12/08/1980, both of which are acceptable, but I was not able to do so.
Kindly assist.
Thanks.
Lennox.
Post by Lennox Jacob
Thanks Russ and Norman,
So, I use a text editor and manually change Tuesday, August 12,
1980 to Tuesday, 12 August 1980 and all is well. When I save and
then reopen there is no problem because the formatting has already
been corrected.
It means that I have to change the date of birth manually when I
want to open any old file.
That is what I would like to get done, changing that old format to
the new format, seemlessly, in the background.
Any advice or recommendations.
If you read the "date" in a s a string see if it has 2 commas and if
it does you know it is the old format
Delete the second comma and away you go
something like
// assuming the date of interest is in dateStr already
select case countFields(dateStr,",")
case 2
// this date is already like Tuesday, 12 August 1980
case 3
// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string
weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)
dateStr = weekDay + ", " + month + " " + year
else
// something else
end select
// now use parse date on dateStr
_______________________________________________
REAL Software has decided to consolidate this mailing list with the
online Forums. On Monday, February 12, 2007, this mailing list
will no longer be active. We encourage you to continue your
REALbasic and REAL SQL Server discussions on the Forums. If you
are not presently a member of the forum, please sign up today at .
---------------------------------
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
_______________________________________________
REAL Software has decided to consolidate this mailing list with the
online Forums. On Monday, February 12, 2007, this mailing list
will no longer be active. We encourage you to continue your
REALbasic and REAL SQL Server discussions on the Forums. If you
are not presently a member of the forum, please sign up today at
<http://forums.realsoftware.com>.
Norman Palardy
2007-02-12 05:35:32 UTC
Permalink
Post by Lennox Jacob
Thanks Norman,
But I have been trying this and many of my modifications of it
// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string
weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)
dateStr = weekDay + ", " + month + " " + year
to get from Tuesday, August 12, 1980 to Tuesday, 12 August 1980 or
12/08/1980, both of which are acceptable, but I was not able to do so.
dim weekday as string
dim monthPart as string
dim month as string
dim day as string
dim year as string

weekday = nthfield(dateStr,",",1)
monthPart = nthfield(dateStr,",",2)

day = nthfield(monthPart," ", 1)
month = nthfield(monthPart," ", 2)

year = nthfield(dateStr,",",3)

dateStr = weekDay + ", " + day + " " + month + " " + year
Lennox Jacob
2007-02-12 12:56:20 UTC
Permalink
Thanks Norman,
Sorry to be a pain, I tried that myself too, but it gives Tuesday, August 1980 - the date 12 is not there, try it out in an editfield in RB2007R1 and you will see.
Lennox
Post by Lennox Jacob
Thanks Norman,
But I have been trying this and many of my modifications of it
// this date is like Tuesday, August 12, 1980
dim weekday as string
dim month as string
dim year as string
weekday = nthfield(dateStr,",",1)
month = nthfield(dateStr,",",2)
year = nthfield(dateStr,",",3)
dateStr = weekDay + ", " + month + " " + year
to get from Tuesday, August 12, 1980 to Tuesday, 12 August 1980 or
12/08/1980, both of which are acceptable, but I was not able to do so.
dim weekday as string
dim monthPart as string
dim month as string
dim day as string
dim year as string

weekday = nthfield(dateStr,",",1)
monthPart = nthfield(dateStr,",",2)

day = nthfield(monthPart," ", 1)
month = nthfield(monthPart," ", 2)

year = nthfield(dateStr,",",3)

dateStr = weekDay + ", " + day + " " + month + " " + year
_______________________________________________
Unsubscribe:


REAL Software has decided to consolidate this mailing list with the online Forums. On Monday, February 12, 2007, this mailing list will no longer be active. We encourage you to continue your REALbasic and REAL SQL Server discussions on the Forums. If you are not presently a member of the forum, please sign up today at .



---------------------------------
We won't tell. Get more on shows you hate to love
(and love to hate): Yahoo! TV's Guilty Pleasures list.
Norman Palardy
2007-02-12 16:10:21 UTC
Permalink
Post by Lennox Jacob
Thanks Norman,
Sorry to be a pain, I tried that myself too, but it gives Tuesday,
August 1980 - the date 12 is not there, try it out in an editfield
in RB2007R1 and you will see.
Lennox
There's an extra space in there before " August" so it messes up the
splitting of the day and month.
And I had the day and month backwards

dim weekday as string
dim monthPart as string
dim month as string
dim day as string
dim year as string

weekday = nthfield(dateStr,",",1)
monthPart = trim(nthfield(dateStr,",",2)) // note the TRIM !!!!

day = nthfield(monthPart," ", 2)
month = nthfield(monthPart," ", 1)

year = nthfield(dateStr,",",3)

dateStr = weekDay + ", " + day + " " + month + " " + year

Loading...