Automatically format date to right format in Datepicker - vue.js

I use Vue3DatePicker with 2 dates (range picker). I put a format on the range, but if the format is slightly different it does not work. How can I put a mask/format on it so it automatically adjusts it to the correct format?
For example:
Date 08-02-2023 works. Date 8-02-2023 does not work. 08/02/2023 Also does not work. How can I catch these dates and put them in the right format, so the datepicker works for those inputs?
<Datepicker
:format="'dd-MM-yyyy'"
:model-value="date"
range
text-input
:text-input-options="{ format: 'dd-MM-yyyy' }"
#update:model-value="setDate"
/>

Related

How to conditionally format date cells in a matrix in quicksight?

Can not seem to conditionally format date values in quicksight. What am I doing wrong?
My date fields are in the date format and I have added them to a matrix as shown and when I try to conditionally format using 'Add background color' the pop up does not even open.

How to do di-directional syncing between a date input field and a number input field?

I am attempting to create a "birthday" component in Vue.js. I have 2 v-text-field components, one that has a type="date" and another that has a type="number".
The idea is that the user will either enter a birth date or their age. If they enter their age, it will change what's in the date input and vice versa.
Everything works great except when I change the age input. Instead of updating the date input value, it just reverts it to mm/dd/yyyy.
I created a codepen here
I can't figure out why it's not working as the underlaying data property is correct (i added a derived text area to show that the properties are updating correctly that you can see in the example below the "date of birth" input.
Your problem is about difference between what format does age calculation and date calculation use. second one produces YYYY-MM-DD while first one produces MM/DD/YYYY.
Try this
this.birthDate = newBirthDate.toISOString().substring(0, 10)
instead of yours in age calculation, or whatever is more appropriate.

Trim function causes date format change

Firstly, important to note that I'm in the UK so standard date format is dd/mm/yyyy
In a A1, I have a date: 02/05/2017 (dd/mm/yyyy)
I can confirm this in the immediate window:
?CLng(Range("A1").Value)
42857
Now, if I do the following:
Range("A1").Value = Range("A1").Value
you can probably guess, nothing happens - the date is still 02/05/2017 and the numeric value is still 42857
But if I use trim with it:
Range("A1").Value = Trim(Range("A1").Value)
The date is changed to 05/02/2017. This isn't just formatting - the numeric value has also changed to 42771.
What is it about the Trim() method that causes the date to be read in US format and then converted back to UK format with a new date value? Is this a bug?
From the discussion in comments:
The default or "token" format in VBA (not Excel itself, as Macro Man rightly pointed out) is US English - regardless of regional settings or cell formatting.
When you do VBA text functions on a date, the output of those functions are in text format. So the result of Trim(Range("A1").Value) is a string. This string happens to resemble a proper US date, so when you insert it into a cell, Excel recognizes it as a US date.
So two implicit conversions happen. The first happens when you read the cell contents and pass it to trim(): date->text conversion; the second happens when you write it back to an Excel cell: text->date conversion. The second conversion has no information about the format, so it assumes US English.
(You should be able to achieve the same result with any text function, not just trim().)
I found out that if you add "'" before the date, the date is not altered.
Range("A1").Value = "'"&Trim(Range("A1").Value)

asp:boundfield dataformatstring not working

I am working on a vb.net web application and I am displaying a Gridview with rows containing datetime, the data is coming from database. In my aspx file, within my asp:boundfield I am trying to change the date format (which at the moment is mm/dd/yyyy hh:mm:ss) to "dd MMM yyyy" (no time) and I have tried using the dataformatstring and HtmlEncode="True/False" (both) but still it does not change the date format in the GridView. The code is as shown below -
<asp:BoundField DataField="STF_JOINED" HeaderText="Joined" SortExpression="STF_JOINED" HtmlEncode="False" DataFormatString = "{0:d}" ReadOnly="True">
In the above code I tried to format the date to shortdate for the moment but it didn't work. I would still want the date format to be in "dd MMM yyyy" format.
I have tried a number of solutions from stackoverflow but none of them seem to work for me. Can someone please tell me what I am doing wrong or what I should be doing, by giving a small example code.
You don't need HtmlEncode at all.
For DataFormatString You have to use, for example, {0:dd MM yyyy} or {0:dd.MM.yyyy} beacuse Your database field data type is datetime not date (where dd represent day, MM month and yyyy year. Be aware for MM, if You write mm it's represent minutes).
<asp:BoundField DataField="STF_JOINED" HeaderText="Joined" SortExpression="STF_JOINED" DataFormatString = "{0:dd MM yyyy}" ReadOnly="True">
Tested and working.
You can read more about data format strings here : BoundField.DataFormatString Property
There You can see examples for Standard and Custom format string (links under every table).

Format of Date Time Picker

dtpPurDate.CustomFormat = "dd-MM-yyyy"
dtpPurDate.Text = DT.Rows(i)("PurDate")
In Access, PurDate is 1/1/1900 but in date time picker it's shown as 01-01-2000. At this time, short date format of system regional setting is like
If it's d/M/yyyy, it's shown as 01-01-1900.
How should I set the date time picker whatever regional setting is?
You're using the custom format string dd-MM-yyyy. With this custom format string, the - character is treated as a literal, and copied to the result string unchanged. Thus, all of your dates will use - as the date separator, regardless of your environment's regional settings.
Instead, you want to replace the literal - with the magic /. This is a special value that indicates to the control you want to use the appropriate localized date separator, as retrieved from the DateTimeFormatInfo.DateSeparator property of the current culture.
So your custom format string should be re-written as: dd/MM/yyyy.