Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Can anyone explain this? (date/time conversion)


Go to solution Solved by David Jondreau,

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

Recommended Posts

Posted

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

 

 

Posted

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.

Posted

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.

  • Solution
Posted

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 ) ]

Posted

So if it is 23:55 on the 1st of Jan, then it should round up to 2nd of Jan?

Posted

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

This topic is 4249 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.