Working with Date/DateTime in Database and Wappler

#1

OS info

  • Operating System : Windows 10.0.17763
  • Wappler Version : 1.9.9

Problem description

In my database, I have multiple datetime fields in various tables. My issue is similar to that described in the topic, https://community.wappler.io/t/dates-dynamic-dates-and-date-picker/5023, where my data is stored as 2018-10-17 21:09:30.

On my insert page, I utilize the date field and it submits the date properly. When I display the data on a page, I can format it and it appears in the standard MM/dd/yyyy format.

The issue is on the update page. When using the date form field, nothing is displayed. As indicated in the above post, I changed the field from date to text and the date is displayed in the format saved in the database, 2018-10-17 21:09:30.

While I can understand this format and update it as needed, my end users will not be able to.

I have looked and clicked on everything I can think of, but I can not see how to format the date on an update field to a MM/dd/yyyy format.

date1

Any assistance would greatly be appreciated.

Thanks

#2

Why not use the date picker component in your form, instead of the regular html5 date field?
You can then format the date on the front end as needed, while the date will be inserted in the standard MySQL date format.
Screenshot_62

#3

Ok, I see what my issue is now. I need to not only use the text field with the date picker component in wappler, but also use a char field in the database, not a datetime field as mentioned in Date picker query

Thanks @Teodor

#4

I am not sure what do you mean. You can use date or datetime fields with the date picker :slight_smile: why using a char field?

#5

facepalm of course you are right. I see that now.

I was in the process of changing my data to from datetime to char based on the video I watched at Date picker query.

#6

No, you don’t need a char field :slight_smile: just use the standard date/datetime fields for your db table.

#7

I have set up an update page and have been able to set up the date range picker to insert the dates into the database, but I am having trouble with displaying the start and end dates on the update page after the start and end dates have been inserted.

I tried using the Dynamic Attributes with the start date and nothing showed on the page.

date6

I tried using the custom dates option and nothing showed on the page.

date5

I tried using the Dynamic Attributes with the min and max dates and nothing showed on the page.

date4

What would be the way to show the start and end date fields on an update page that has a field using the date range picker?

#8

Just use the dynamic attributes > input > value and select the expression from your data source which returns the data from your database.

#9

I think that’s where I am having trouble.

In my first example, I tried serverconnect1.data.queryprelimid[0].pc_preliminary_date_start alone as the value and that did not work.

I then tried serverconnect1.data.queryprelimid[0].pc_preliminary_date_start + ‘-’ + serverconnect1.data.queryprelimid[0].pc_preliminary_date_end and that did not work.

I then tried serverconnect1.data.queryprelimid[0].pc_preliminary_date_start + serverconnect1.data.queryprelimid[0].pc_preliminary_date_end and that did not work.

#10

If this expression is returning a date from your database, then this is what you need to select in your date picker.
Please provide a link where I can check what’s wrong.

#11

I sent you a private message with the details because it is a secured page.

1 Like
#12

Thanks Scott,
I’ll check your page and will let you know what’s wrong there :slight_smile:

#13

Did you install “moments”? That’s where I got stuck.
<input type="date" class="form-control" id="inp_startdate" name="startdate" dmx-bind:value="updatefill.data.query1[0].startdate" aria-describedby="inp_startdate_help" placeholder="Enter Startdate">

#14

@web-works i got the link in a private message, that’s not the issue here.