Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Get Date from Text timestamp

Featured Replies

Hi there,

 

I am trying to extract a date from an imported timestamp but not having any success.

 

Here's what I have :

 

A timestamp field where I import a timestamp from an external source. The timestamp is formatted as follows:

 

SaleDate = 2015-03-13 07:50:16

 

I am trying to set a variable using SetVariable [$Date; Value:GetAsDate ( Sales::SaleDate )]

 

But all I get is ?

 

How exactly do I convert that to a date only field?

 

I tried LeftWords to extract the date part only, but filemaker still doesn't recognise that as a valid date. my system is set to dd/mm/yyyy So I guess I will have to use a number of text functions to rebuild the date in the correct format.

 

Is there any other simpler option?

 

I'd rather avoid using text based functions incase the formats vary.

my system is set to dd/mm/yyyy So I guess I will have to use a number of text functions to rebuild the date in the correct format.

Your guess is entirely correct. Try =

Date ( Middle ( SaleDate ; 6 ; 2 ) ; Middle ( SaleDate ; 9 ; 2 ) ; Left ( SaleDate ; 4 ) )

 

Is there any other simpler option?

Not really.

 

I'd rather avoid using text based functions incase the formats vary.

 

Well, formats are not supposed to "vary". That's why we have them. A format is the agreed way to transmit data from one system to another. The receiving system relies upon the transmission conforming to the agreed format - otherwise things just won't work.

 

If you want your target system to anticipate changes in the transmitted format, you will have to build some degree of intelligence into it (by stringing together even more text manipulations). And no degree of intelligence - neither human nor artificial - will be able to tell you if "1/2/2015" is January 2 or February 1.

  • Author

Thanks comment:

 

I ended up going with :

 

Right ( LeftWords ( sale_date ; 1 ) ; 2 ) & "-" & Middle ( LeftWords ( sale_date ; 1 ) ; 6 ; 2 ) & "-" & Left ( sale_date ; 4 )

 

Does adding the: Date (  ) function make a difference?

 

for example can I just use:

 

Right ( LeftWords ( sale_date ; 1 ) ; 2 ) & "-" & Middle ( LeftWords ( sale_date ; 1 ) ; 6 ; 2 ) & "-" & Left ( sale_date ; 4 )

 

Or is there a difference if I used:

 

Date ( Right ( LeftWords ( sale_date ; 1 ) ; 2 ) & "-" & Middle ( LeftWords ( sale_date ; 1 ) ; 6 ; 2 ) & "-" & Left ( sale_date ; 4 ) )

 

I can see overall your solution is neater than mine, I'll probably switch it over.

 

thanks for the input.

for example can I just use:

 

Right ( LeftWords ( sale_date ; 1 ) ; 2 ) & "-" & Middle ( LeftWords ( sale_date ; 1 ) ; 6 ; 2 ) & "-" & Left ( sale_date ; 4 )

 

if you do that, you will end up with a text result of "13-03-2015". If you then set the result type of the calculation field to Date, it will do the equivalent of =

GetAsDate ( "13-03-2015" )

which will work for as long as your file is set to use the dd-mm-yyyy format. That's why using the Date() function is preferable - it will work the same no matter what the locale settings are.

 

 

Or is there a difference if I used:

 

Date ( Right ( LeftWords ( sale_date ; 1 ) ; 2 ) & "-" & Middle ( LeftWords ( sale_date ; 1 ) ; 6 ; 2 ) & "-" & Left ( sale_date ; 4 ) )

 

Well yes, there is a big difference: that wouldn't work at all. The Date function requires 3 parameters (all of them numbers) and the order of the parameters is always (month; day; year)

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.