How can I convert a string to a date and store the results in a datetime field

I am looking at a date in string format. I am converting it to a date with date from string block then when try to assign the results to a datetime field nothing is stored.

I don’t see any errors in the browser console

my logging shows the following
record id date string
3304577 date 2/11/2019#Mon Feb 11 2019 00:00:00 GMT-0500 (Eastern Standard Time)##

result from date from string between the trailing ## is the output from the
property I attempted to store the date in. so its blank.

here is the code(less) i am trying to use.

CURRENT_CONTROLLER_BEGIN_DT is type string
CURRENT_CONTROLLER_BEGIN_Date is type datetime

what must I do to convert the string into something I can store in a datetime field?
thanks
HH

Hi @hharrington

  1. If you print the result of the date from string does it show the correct value?

  2. What does CURRENT_CONTROLLER_BEGIN_Date value look like in the testobject?
    If you want to set a Date into the testobject to CURRENT_CONTROLLER_BEGIN_Date you need to use a Text with “CURRENT_CONTROLLER_BEGIN_Date” instead of getting this from the testobject

SetPropertyIn

  • “of” an object where you are going to set value (testobject)
  • “property” for set (CURRENT_CONTROLLER_BEGIN_Date)
  • “value” to set

Regards,
Vlad

Thanks for taking a look at this.

  1. the result of date from string block is “Mon Feb 11 2019 00:00:00 GMT-0500 (Eastern Standard Time)”

  2. testobject is the first row of my table using the “get first object from table” block.
    the table has column CURRENT_CONTROLLER_BEGIN_DT that is type string and is storing a date. It also has column CURRENT_CONTROLLER_BEGIN_Date that is type datetime and has no data as its a column I added to the table after import.

I am trying to convert the string in CURRENT_CONTROLLER_BEGIN_DT of the same table and store it in CURRENT_CONTROLLER_BEGIN_Date (also in the same table )

my plan was to covert the timestamps in CURRENT_CONTROLLER_BEGIN_DT as strings to CURRENT_CONTROLLER_BEGIN_Date as datetimes.

from my understanding, Backendless really wants to use unix timestamps for dates and I think doing a search on that will be faster than trying to run a date search on a string (if that’s even possible )

HH

that’s correct, using timestamps is way way better for working with dates

Cool.

so I can see the output of date from string looks correct, I just cant seem to store it in a datetime field.

Thanks,
HH

to convert a string to timestamp object try the following logic

ok I have this:

but testobject.CURRENT_CONTROLLER_BEGIN_Date is still blank

so when I print out the value of CURRENT_CONTROLLER_BEGIN_Date immediately after i set it (see below) no value is printed.

that block output looks like this “3304577 date 2/11/2019#1549861200000##”

I was expecting the new timestamp to show up between those last two ##

Sorry for being so obtuse.

HH

replace blocks connected to the “property” input to a simple Text block as on my screenshot

OMG,

This

should have been this

because I was already referencing testobject < pagedata in the “set proterty in” part of that block.

Thank you for your patience while I fumbled around with this.

HH

1 Like