Xano Posting Data - Date

Ive been having the worst time trying to figure this problem out.

I’m trying to create a form with a xano database. A user create an account, log in, then fill out the multiple forms, stop wherever they are and log out and return later to finish filling out the form.

I figured out setting the int value for a logged in user, seems to be working now, but what I can’t seem to figure out is posting data to Xano. I had it working at one point, but now its with a logged in user its just error after error. First it was the int fields, so I changed them all to strings (I want a more elegant solution for numbers but if you post blank data, Xano doesn’t like it). Then it was email address, even though its not a required field, now its the birthdate field. I would think that if Xano and WeWeb is integrated they would have had this figured out, but I must not be smart enough to see the solution.

Here’s the error, and without just changing everything to string because it seems any formatted data doesn’t work I’d love to get a win here and figure out why this doesn’t work.

I will note: reading IN that data to WeWeb seems to work fine. Just POSTING to Xano doesn’t.

Here’s the error:
{“code”:“ERROR_CODE_INPUT_ERROR”,“message”:“Invalid timestamp format.”,“payload”:{“param”:“birthdate”}}"

responseText: “{“code”:“ERROR_CODE_INPUT_ERROR”,“message”:“Invalid timestamp format.”,“payload”:{“param”:“birthdate”}}”

1 Like

From the error it looks like you probably need to transform the date into a timestamp

There is a formula to convert a date into a timestamp:
image

image

I was sure that was going to work! Still has an error on the timestamp format. I tested the number it posted and Xano still has the error:
2022-10-11_11-42-34

code: “ERROR_CODE_INPUT_ERROR”
message: “Invalid timestamp format.”

Heres my date field in Xano:
2022-10-11_11-35-03

I had a ton of trouble with date/time between weweb and xano also.

First, there are different fields in xano for Date and Timestamp. If you want to sort by date in weweb, you need to use timestamp because the xano-Date value comes in as a string. Xano also uses milliseconds instead of seconds, so their timestamp is longer.

I used the date range picker in Weweb, which provides a format that needs to reformatted for xano. I think I used formatDate(start_date) in weweb, which xano accepts and converts to a timestamp. That may be under the extra dates plug-in you can add in weweb.

It seems odd to store data like a start and end date as a timestamp, but it may be important if you work across timezones, plus it’s the only method I found that achieves all my needs

1 Like

Thanks for the note. I’m not sure it will work for my case as I’m just trying to have a date, not date time or date range and I don’t see an option to remove one side unless you had a thought on that? I may just store it as a text field for now as I just need to get it working for now (proof of concept) it seem like none of the data formatting between Xano and WeWeb play nicely, any time I’ve tried to use anything other than text format it always burps an error.

Can you describe the steps of your workflow that are generating the error?

I tried and it just works.

Here is my setup:

  • Create an example table whit a field called “dob” of type timestamp.
    image

  • Create a record in the table.

  • Add xano plugin to the data sources in weweb and setup api key and instance.
    image

  • Create an example form with a date picker.
    image

  • Add a workflow to the form container “on submit” with a xano request Action.
    image

  • Set the options of the request action to pint to the right xano endpoint. Modify the first record in the table.

  • For the field “dob” bind the value to the date picker transforming the date into a timestamp.
    image

  • Test the workflow. It just works.


Things to notice:

  • if you need a date in xano use the timestamp type
  • the nocode timestamp function in weweb returns milliseconds, the same of what xano requires for timestamp. No need for other conversions.

Interesting, This makes sense now! This lil four letter word is an interesting issue for myself who’s not a coder. It’s been eye opening. I had 3 things going on which was why it didn’t work. The date field was reading in as “text” on Xano API instead of a date, something changed it, not sure what, and in my hurried testing i changed the data push from WeWeb into timestamp, and the “dob” field as “date” instead of timestamp. Once i went through the process again I was able to align them all to a date field and now they work, both in timestamp format and in date only format.

Thanks for the detailed followup!

As pointed out in this post the timestamp function returns only the current date as a timestamp.

To correct conversion is a formula with a bit of javascript:


image
image

1 Like