Jump to content

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

Recommended Posts

I am trying to convert text to date using GetAsDate function

I referred to an old answer on below link: But I couldn't get it working , my system's date format is 2016-01-05 and I used the syntax: 

GetAsDate ( Right ( date_start_printing_text;4 ) & "-" & Left ( date_start_printing_text;3 )  &  "-" &  Middle ( date_start_printing_text ; 5 ; 2 ) ) to convert the value format 01-05-2016 

date_start_printing_text is a calculation field, returns text value,  which calculates its value from a text field with timestamp value using Left function

Left ( timestamp_printing ; Position ( timestamp_printing ; " " ; 1 ; 1 )) 

 

Edited by dav1089
Link to comment
Share on other sites

Well, if you look at the string you are trying to convert to date  - i.e. the result of =

Right ( date_start_printing_text;4 ) & "-" & Left ( date_start_printing_text;3 )  &  "-" &  Middle ( date_start_printing_text ; 5 ; 2 )

you will see that when the input is "01-05-2016" the output is "2016-01--5-" - so that's not going to work.

I would also suggest you use the Date() function instead of GetAsDate() - that way the calculation does not depend on the date format being used by your file. Try =

Date (
Left ( date_start_printing_text ; 2 ) ;
Middle ( date_start_printing_text ; 4 ; 2 ) ;
Right ( date_start_printing_text ; 4 )
)

 

--
P.S. Why do you need the date_start_printing_text field? You could extract the date components directly from the original timestamp string.

 

Edited by comment
  • Like 1
Link to comment
Share on other sites

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