woz Posted April 22, 2013 Share Posted April 22, 2013 This is just an example to demonstrate my problem... getastimestamp( getasnumber((timestamp(date(1;1;2001) ; time(0;0;0)))) ) returns 1/01/2001 00:00 getasdate( getasnumber((timestamp(date(1;1;2001) ; time(0;0;0)))) / 86400 ) returns 31/12/2000 (Australian formatted date) Am I missing something obvious? Using FMPA 12.0v3 Link to comment Share on other sites More sharing options...
David Jondreau Posted April 22, 2013 Share Posted April 22, 2013 Looks like you're missing about a day's worth of seconds. I'm not sure what exactly is going on here, but I think it's a "mythical" problem, based on our not understanding how FileMaker is counting days and seconds. What is your actual problem? Whatever it is, I think you're better off not not dividing by 60*60*24, but simply using GetAsDate. GetAsDate ( Timestamp ( Date ( 1 ; 1 ; 2001 ) ; Time ( 0 ; 0 ; 0 ) ) ) returns the result you're expecting. Link to comment Share on other sites More sharing options...
woz Posted April 23, 2013 Author Share Posted April 23, 2013 Thanks for reply David I was trying to round a timestamp to the nearest hour then separate it into date and time. I've figured out how... Set Variable [$now; Value:Get( CurrentHostTimeStamp )] Set Variable [$RoundedDate; Value:GetAsDate( GetAsTimestamp( Round( $now /3600 ; 0 ) *3600 ) )] Set Variable [$RoundedTime; Value:Time( Round( GetAsTime( $now ) /3600 ; 0 ) ; 0 ; 0 )] I'd still welcome better ways if any. Link to comment Share on other sites More sharing options...
Solution David Jondreau Posted April 23, 2013 Solution Share Posted April 23, 2013 This may be a little clearer... Set Variable [ $now ; Get ( CurrentHostTimestamp ) ] Set Variable [ $round.now; GetAsTimestamp ( Round ( $now / 3600 ; 0 ) * 3600 ) ) ] Set Variable [ $date ; GetAsDate ( $round.now ) ] Set Variable [ $time ; GetAsTime ( $round.now ) ] Link to comment Share on other sites More sharing options...
mr_vodka Posted April 23, 2013 Share Posted April 23, 2013 So if it is 23:55 on the 1st of Jan, then it should round up to 2nd of Jan? Link to comment Share on other sites More sharing options...
woz Posted April 24, 2013 Author Share Posted April 24, 2013 This may be a little clearer... Set Variable [ $now ; Get ( CurrentHostTimestamp ) ] Set Variable [ $round.now; GetAsTimestamp ( Round ( $now / 3600 ; 0 ) * 3600 ) ) ] Set Variable [ $date ; GetAsDate ( $round.now ) ] Set Variable [ $time ; GetAsTime ( $round.now ) ] Slightly, thanks David So if it is 23:55 on the 1st of Jan, then it should round up to 2nd of Jan? Yes Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 4030 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