fmwebschool.com
Top Experts [learn more]Top 4-10
webko

9743 K
bandmandq

2458 K
Genx

1525 K
4. tcmeyers
5. kbata
6. Martie
7. Hammerton
8. rrenfrow
9. bneeman
10. plegler
Welcome, Guest. Please login or register.
May 23, 2013, 04:31:12 PM

Login with username, password and session length
Search:     Advanced search
FMWebschool releases more educational FMStudio webinars - check them out here:
http://www.fmwebschool.com/webinars.php
27464 Posts in 6066 Topics by 1523 Members
Latest Member: donok
* Home Help Search Calendar Login Register
+  fmwebschool.com
|-+  FMTouch
| |-+  FMTouch - FileMaker Databases on the iPhone and iPod iTouch
| | |-+  [SOLVED] Working with Dates
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: [SOLVED] Working with Dates  (Read 1797 times)
North2Alaska
Newbie
*
Offline Offline

Posts: 14


[SOLVED] Working with Dates [Was worth 100 Kudos points!]
« on: December 31, 2009, 07:31:32 AM »
See Answer

I've been reading a lot about dates and date formats.  I believe at this time date formatting does not work in FMT.  So, I am trying to create a work around to a problem I am having.  I have a relationship built on the Year of a birthDate.  Of course, simply getting
Code:
Year ( Birthdate )
does not work in FMT because it does not support the Year function.  OK, I can deal with that by forcing Year to be dealt with as a string by using
Code:
Left ( Birthdate ; 4 )
.  This works in FM but does not work in FMT as FMT's default for dates is YYYY/MM/DD instead of FM's default of MM/DD/YYYY (this could be a localized issue.  I'm in the US.)

I have to come up with a solution that works both in FM and FMT.  I thought I might be able to use an IF statement to figure out which function to use, Year or Left depending on if it is FM or FMT.  I just can't seem to figure out a solution.   Suggestions?
Logged
rrenfrow
FMTouch Developers
Hero Member
*
Offline Offline

Posts: 253
Kudos: 225


« Reply #1 on: December 31, 2009, 09:56:42 AM »

What about changing the date format in the FM file?  I know it is not "American" but it would make them compatible.  Format the field as a date, then use the custom formatting choices to format it as YYYY/MM/DD.

It's working backward, but, hey, it should work.

Raylene
Logged
North2Alaska
Newbie
*
Offline Offline

Posts: 14


« Reply #2 on: December 31, 2009, 10:31:22 AM »

I don't think it is a formatting issue from the individual layout perspective.  FM stores dates as a number and then displays them by a default format.  I don't find anyplace to set a default format for a data globally for the whole database.  I can set how the layout will display the date, but that doesn't help when FMT uses a different default format.  :-(
Logged
rrenfrow
FMTouch Developers
Hero Member
*
Offline Offline

Posts: 253
Kudos: 225


« Reply #3 on: December 31, 2009, 10:59:50 AM »

OK.  You could add one more data entry field for year.  Not great, but it would give you the year data.

Stabbing in the dark here, but wishing I could help.

Raylene
Logged
North2Alaska
Newbie
*
Offline Offline

Posts: 14


« Reply #4 on: December 31, 2009, 11:16:57 AM »

That is really the only option at the moment.  So, what I have decided to do is create a calculated field that is = 2010 with the hope that by the end of the year we will have the date manipulation functions and I can replace my hard code value with Year ( Birthdate ). 

Thanks all for the attempts...  Wink
Logged
rrenfrow
FMTouch Developers
Hero Member
*
Offline Offline

Posts: 253
Kudos: 225


« Reply #5 on: January 01, 2010, 12:17:28 PM »

One more wild and crazy idea.  What if you had two fields for year each calculated appropriately for its use....one you use for FMP and one you use on the layouts for FMT.

Raylene
Logged
North2Alaska
Newbie
*
Offline Offline

Posts: 14


« Reply #6 on: January 02, 2010, 07:01:09 AM »

In some cases this may work.  My problem is I'm using the results as a join and as such two columns would not work.
Logged
rrenfrow
FMTouch Developers
Hero Member
*
Offline Offline

Posts: 253
Kudos: 225


« Reply #7 on: January 02, 2010, 07:22:57 AM »

OK.  I'm giving up and leaving you alone.  I'm not helping.  Sorry!!!  I wanted to.  You have a really complex solution!  Hope you figure something out.

Raylene
Logged
North2Alaska
Newbie
*
Offline Offline

Posts: 14


« Reply #8 on: January 02, 2010, 08:07:55 AM »

Thanks so much for your attempts.  Yes, it is somewhat complex and gets pushed over the top when working with FMT and it's subset of FM functionality.

What I ended up doing is hard coding a value of "2010".  I'm betting the farm that FMT will have the date Functionality included by the end of the year.
Logged
TheTominator
Newbie
*
Offline Offline

Posts: 10
Kudos: 150


« Reply #9 on: January 10, 2010, 06:47:06 AM »

If I understand the current problem correctly, you have got it down to writing a calculation to pick the 4 digit year from a string that can be either "YYYY/MM/YY", "MM/DD/YYYY", or "DD/MM/YYYY".  (There are additional possibilities of "YYYY-MM-DD" and similar for FileMaker Pro representation in different conventions around the world.)

What these all have in common is that the year is 4 digits while the stuff you don't want is 2 digits.  The year always appears either at the beginning or the end.  It never appears in the middle.  The separators used are always symbols that FileMaker treats as word boundaries.

It is unlikely that you will be using a year before 1000 AD.
Use this criteria to choose between using the first 4 digits or the last 4 digits.

Restricting ourselves to functions supported by FMTouch to break apart the field DateString that has your date as a string...

If(
GetAsNumber(Left(DateString; 4)) < 1000;
GetAsNumber(Right(DateString; 4));
GetAsNumber(Left(DateString; 4))
)
Logged
North2Alaska
Newbie
*
Offline Offline

Posts: 14


« Reply #10 on: January 13, 2010, 08:52:28 AM »

Thanks, this worked...
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!