bcooney Posted September 12, 2011 Posted September 12, 2011 I'm drawing a blank on this. I'd like to determine if it is 1am, and if so run a script on the robot I've set up. If I do If ( Hour ( GetCurrentTime) =1 ) it seems to run at both 1am and 1pm. It's probably simple. Do I need to use timestamp and patterncount for "am"?
bcooney Posted September 12, 2011 Author Posted September 12, 2011 I am familiar with military time. How does that help me?
doughemi Posted September 12, 2011 Posted September 12, 2011 Get(CurrentTime) format is dependent on your system time settings. Your PatternCount solution is probably the easiest.
bcooney Posted September 12, 2011 Author Posted September 12, 2011 OK. Just seemed too complicated to be correct.
LaRetta Posted September 12, 2011 Posted September 12, 2011 Hi Barbara, Your theory works. If 1 am it should produce 1 and if 1 pm it should produce 13. Do you have that calculation set to unstored?
bcooney Posted September 12, 2011 Author Posted September 12, 2011 Hi LaRetta, I see that Hour (Get (CurrentTime)) returns 1, regardless of am or pm. So, I'm also looking at Patterncount for "AM". I never get 13. This is not a calc field, it's an If ( ) in a script: If ( the hour is 1am) run subscript endif
imoree Posted September 12, 2011 Posted September 12, 2011 http://www.briandunning.com/cf/1337 militarytime(get(currenttime) = 0100 , blah, blah Just an idea
LaRetta Posted September 12, 2011 Posted September 12, 2011 I still don't get it, Barbara. A test of a calc is a test of a calc no matter whether in script or calculation field. Please try the attached. I don't understand what I'm not understanding. Added: Type in any time. Only if 1 am will it display message. You will NOT get 1 regardless of 1 am or 1 pm. If script then you are already within an If()... so to speak. Are you turning it into Boolean by accident? time.zip
Vaughan Posted September 12, 2011 Posted September 12, 2011 Hour ( Get( CurrentTime ) ) =1 FMP might be treating this as a boolean, in which case it may be true for all times. Why not: Get( CurrentTime ) = Time( 1 ; 0 ; 0 ) This avoids any reliance on the client system's time formatting. PS: I haven't looked at LaRetta's demo file, she may have said the same thing.
bcooney Posted September 13, 2011 Author Posted September 13, 2011 This is so odd, and it's obvious that I'm missing something. I started with: If ( Hour (GetCurrentTime) = 1) // could this be the boolean problem? do subscript endif And that evaluated to 1 for both AM and PM. Now I have: If (Hour ( GetCurrentTime) = 1 and Patterncount ( Get (CurrentTime); "AM") do subscript endif I'll try this again today, at 1pm, LaRetta, just to confirm that Hour (Get (CurrentTime)) = 1 at 1pm. In fact, it seems that's what Help says. @Vaughan - thanks. Yes, I can't change the system's time formatting. I like the patterncount better...just seems more solid. I don't trust Time(1;0;0) and I can't have it only run at 1am, but rather during the entire 1am hour is the goal. It's running on a Robot, and I really want btw 1am and 1:59:59am, as the Robot has other scripts to run. @imoree, yes I could convert to Military using the CF, but that's a bit of overhead that isn't needed, imho.
LaRetta Posted September 13, 2011 Posted September 13, 2011 I am unable to reproduce your results. New file created under Windows XP Professional, SP3, FMPA11. Regional settings shows time as 12-hour format with AM and PM. But that is not what FM stores in the field; it is only what is displayed. Testing Get ( CurrentTime ) and no matter my system settings, 1 PM is 13 and 1 AM is 1 and calculations (either as fields or as script) supports it. Just create script step: Show Custom Dialog [ Hour ( Get ( CurrentTime ) ) during any PM and I believe that it will display military hour for you (greater than 12). But you keep writing the 'script steps' as calcs and the calcs are incorrect and I find it confusing. I know you were in a hurry but the calc you have provided will be accepted by FM (after adding the open parens between Get and Current but it is still invalid. Is there more to your script or the calculation than you have shown? You wrote this calc twice: If ( Hour (GetCurrentTime) = 1) // could this be the boolean problem? ... could the problem be that you are actually typing the calc as you are typing it here instead of: Hour ( Get ( CurrentTime ) ) = 1 As for testing for AM or PM, I would far more trust time or date functions than text functions when working with dates or times. Not all system OS' are set up using AM or PM and it might fail (although I have not tested this on every possible configuration). I can tell you that, even with OS settings set to AM/PM, a User can type 14 into a time field and it is accepted as 14 hours. If it is set to display 12-hour then it will display PM. But a test of PatternCount ( timeField ; "PM" ) on a record with 14 in the time field (which displays as 2:00:00:00 PM) fails. Users can enter a mix of many combinations into time fields, just as they can into date fields. Only FM's date and time functions can properly interpret the many combinations of OS setting and User entry. :)
Vaughan Posted September 13, 2011 Posted September 13, 2011 Barbara, is there a custom function called GetCurrentTime being used? If so, perhaps the result it returns is text and not time. Which reminds me to suggest to check the data type of all fields and calculations. :)
bcooney Posted September 13, 2011 Author Posted September 13, 2011 I apologize. I am being sloppy with this. Yes, LaRetta, my script is: If ( Hour (Get (CurrentTime)) =1) do subscript end if However, today at 1pm, i opened data viewer and got 13 (which is what I expected when i started this mess). Don't waste more of your time on this, I don't know what I did.
Recommended Posts
This topic is 4877 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 accountSign in
Already have an account? Sign in here.
Sign In Now