dav1089 Posted June 22, 2016 Posted June 22, 2016 (edited) 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 June 22, 2016 by dav1089
comment Posted June 22, 2016 Posted June 22, 2016 (edited) 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 June 22, 2016 by comment 1
dav1089 Posted June 23, 2016 Author Posted June 23, 2016 Hi, It works great .. and I used original timestamp string.. Thank you @comment
Recommended Posts
This topic is 3341 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