Jump to content

This topic is 8342 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a standard date field.

I have a second field that I am trying to get a calculation to work in by looking at the date field, and if it contains a certain day of the week, it shows that date. I have tried 2 basic calculations but cant get either to work:

If(DateField = Day(1), DateToText(DateField), "")

If(DateField=Day(1), DateField, "")

No luck with either one of these. Any ideas anyone.

LR

Posted

quote:

Originally posted by Larry Ross:

If(DateField = Day(1), DateToText(DateField), "")

If(DateField=Day(1), DateField, "")

No luck with either one of these. Any ideas anyone.

LR

try this :

case(dayofweek(date)=1,datetotext(date)," ")

HTH ...

kyle

[ March 30, 2002, 12:14 AM: Message edited by: kyle ]

Posted

Close........

Make sure the calculation field is set to be a Date value, then use the following:

case(dayofweek(datefield)=1, datefield)

Remember Kyle, with a case you don’t need a default value. If you enter no default, the case always returns a False or 0. And in your example we would get a ? in a date field if the case returns a false. To avoid this we would need to use TexttoDate(“”).

Rigsby

Posted

Ok, got this to work. Now is there a way to expand on this so that it loks at two fields? I know this is wrong but it will give you the idea...

Case(Day(fieldname)=1, fieldname) & "

Posted

quote:

Originally posted by Rigsby:

in your example we would get a ? in a date field if the case returns a false. To avoid this we would need to use TexttoDate.

Rigsby

hi, rigsby !

the calc i used will not return " ? ", when the result is false.

you should try it.

that is why i used " datetotext" in a calculation. of course, calc field type must be text , since datetotext is used for calc result.

regards,

kyle

[ March 30, 2002, 02:09 PM: Message edited by: kyle ]

Posted

ok, let's say you have a 2nd date field which you want to compare to.

case(

dayofweek(date)=1 and month(date)=month(2nd date),

datetotext(date)," ")

or

case(

dayofweek(date)=1 and monthname(date)=

monthname(2nd date),

datetotext(date)," ")

HTH ...

KYLE

Posted

quote:

Originally posted by Larry Ross:

Ok, got this to work. Now is there a way to expand on this so that it loks at two fields? I know this is wrong but it will give you the idea...

Case(Day(fieldname)=1, fieldname) & "
Posted

This stuff is getting deeper. Here is another date one:

I have a calculation field with 31 repeating fields. It uses a calculation to look at the day from another field.

Case(Day(FieldName)=1,?,"")

? is where I want it to change the highlight color of a particulat row, say row 2 of 31 if the day from FieldName =1.

I know this is possible, I have seen it done some where. Any thoughts?

Posted

quote:

hi, rigsby !

the calc i used will not return " ? ", when the result is false.

you should try it.

that is why i used " datetotext" in a calculation. of course, calc field type must be text , since datetotext is used for calc result.

regards,

kyle

-----------------------------------

In your example not, because you're using a text field to show the result. But if you use a Date field (as in mine) then it will. The question is why you would want to show a date in a text field? This would prevent filtering of dates, or searches using > or <

If this sollution is found using a Text field, I'll bet there will be another post in a week or two asking how to get the result into a date field. LOL!

"If you want to fit a square peg into a round hole - don't! Use a saw and make the hole square or the peg round. But ask your self, what do I want to do with the peg once it's in there! Because if once it's in there I need a square peg, making it round will only solve my problems in the short term. Or maybe later I need a round hole?:?" See what I'm getting at?

Rigsby

Posted

Hey Larry,

Where exactly do you want to go with this? In your first post you talked about the day of the week, which is why we used:

case(dayofweek)

But now you are just using “Day”, which is not going to return the day of the week.

The next point is that by using a calculation to put a return between 2 values, you MUST use a text field, which will make any kind of date manipulation very hard. If you tell us the grander scale of things, i.e. why you need to do this, we might be able to offer a better solution!

Rigsby

Posted

Actually, I almost have this all done. When I finish it I will post the resulting file. In a nutshell:

The file is a task manager. It lists the tasks, the start dates, due dates, and descriptions. (eventually the file will be relational and recieve this info from an existing database.

There will be ten or so task items per record. Then off to the side of the record is a one-month graphic representation of each task start date and due date. Kind of a flow chart. I have everything working perfectly.

The last piece I was after was a calculation that looks at the main field at the top of the page (March 3, 2002), checks the day, and if it finds a match it will change the color of the field. The purpose of this is I will have one of these fields for each day of the month, and the right one will highlight for that day.

I know there are calendar files out there, but this one is set up for a specific purpose. It will make sense when I post the sample file for download. Just need the one last calculation for looking at the day in one field and changing the color of another.

LR

[ March 31, 2002, 12:29 PM: Message edited by: Larry Ross ]

Posted

hi , rigsby !

i think i should mention few things regarding your post.

first, there are many cases you need to use this datetotext function. specially when you have a text calculation field which need to show text result with dates in it. haven't you seen these cases ? about date filtering things , of course

there are times you need to stick to the date format and there are times you need to stick to text format. and there are cases like above which

both format can be used by little bit of altering of the formular.

with filemaker , there is more than one way to do things.

so unless you had really thought that i would've used a datetotext function without knowing simple date method, there is no point we keep talking about this. bcz you know and i know it. the main thing is does larry knows it. and looks like he got it. so i'm happy and you should ,too.

also i don't think this issue worth 12 or + posts.

people would think may be something going on this topic. but if they look at it they will be disappointed. so that will be embrassment for me and for you ,too.

anyway let's keep it mind that with filemaker , there is more than one way to do things.

regards,

kyle

p.s. --- oh ! about your example, if you had only one square peg, yes you are right. but don't worry about datetotext function. because it will keep comming as you order and it is free.

Posted

OK, here are the result of this long thread. If you want to see the file you can get it here. It is basically a test file for something I will be working on on a bigger scale. The main layout is for entering task names with start /finish dates and description. The Print Report layout will print out a 30 day chart graphically representing the task list. This layout also automatically highlights todays date, and has buttons for scrolling through days, months and years.

.sea file for MAC users

http://63.226.105.147/ftp/guest/Chart.fp5.sea

.zip file for PC users

http://63.226.105.147/ftp/guest/Chart.fp5.zip

LR

This topic is 8342 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.