Validate date using v-validate in Vue.js - vue.js

I want to allow only those date that are equal to or greater than the departure date time field:
<tr v-for="(input,k) in inputs" :key="k">
<datetime
name="departureDateTime"
v-validate="'date_format:yyyy-MM-dd HH:mm:ss|required'"
v-model="input.departureDateTime"
>
</datetime>
<datetime
name="arrivalDateTime" 👇
v-validate="`after:${input.departureDateTime}|date_format:yyyy-MM-dd HH:mm:ss|required`"
v-model="input.arrivalDateTime"
>
</datetime>
<tr>
This is only allowing me dates which are after departureDateTime field in arrival field, but i also want it should allow the same date also i.e. if i fill 27-05-2021 in departure time then it should allow the same date in arrivalDateTime field also and i want to allow only future dates to be filled in both the date fields.
Any help is highly appreciated.

after params are:
after:target,inclusion
...where the inclusion flag (any value) specifies whether to check for dates greater than or equal to target.
So just add ,true after the target date:
<datetime
name="arrivalDateTime" 👇
v-validate="`after:${input.departureDateTime},true|date_format:yyyy-MM-dd HH:mm:ss|required`"
v-model="input.arrivalDateTime"
>
</datetime>
demo

Related

date input field is taking more than 4 character in vue js input type date

I am using Vuejs 3 and when I use input type date it is taking up to 6 characters in the year field. Is there any way to make it take only 4 characters YYYY in the year field?
You can use max attribute for that. e.g.
<input type="date" max="9999-12-31">

How to get Sysdate in qweb/odoo 11?

How to reference Sysdate in qweb in odoo 11?
I need to compare a date with "sysdate" in qweb, but I'm not able to get the current date.
This way you can get date and time
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>
If you want only date
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d')"/>
like this you can get the today's date.
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%d/%m/%Y')"/>

Removing Date from Date/Time field in Access

I'm trying to select records where the start time is between 12:00 midnight and 5:00am using Access. I use this;
Sheet1.[Start Time] BETWEEN #00:00:00# AND #04:59:59#;
But it gives me zero results. I feel it's because "Start Time" is a date/Time field and displays the date before the time. I have tried formatting the field to be a Long Time field, but it keeps the date regardless. How do I remove the date from the field?
TimeValue(MyDate) will give you just the time portion of a datetime field.

In Vue, how do I bind a date object to a date input ? (v-model doesn't work)

// This doesn't work
<input type='date' v-model='store.myDateObject'>
How can I bind a date input to a date object in my store?
Assuming you want your dates as midnight UTC date objects, do this...
<input type='date'
:value='store.myDate.toJSON().substring(0,10)'
#input='store.myDate = new Date($event.target.value)'
>

remove time from sql

Please can any ove suggest me how i can remove time part from sql dates. I have already read 100s of articles and most of them remove the time but leaves 00:00:00 behine which i don't want also i know that i can remove these ZERO's by doing a convert to varchar but unfortunately i cannot change the type of the date column it has to be date type instead of string
Please advise
Thanks
A datetime column in the database will always contain both a date portion and a time portion. SQL Server 2008 introduces types that store only date or only time. But, so long as the column is of type datetime, you'll have to accept that the time portion exists, and you can just ignore it in your application (by applying suitable formatting).
You can add a check constraint to the table to ensure that all entries in the column always have the same time portion (e.g. 00:00:00).
You need to apply a format string to your gridview column to only display the date part. An example of such a string would be dd MMMM yyyy
Is this an ASP.NET gridview? If so there is example code here.
A SQL server DateTime type is a date and a time in SQL 2005 there is no date only field type, you cannot remove the time component and still have a field that is a DateTime type. Your options are the ones you have outlined: Convert to (n)varchar and remove the time componenet, leave it as a DateTime and accept that it has a time component. Why do you wish to remove the time component, what problem would this solve for you.
Further to your comment below, the database is not where you should be formating you Date strings to display in your GridView. You do display layer things in the display layer, in this case in the gridview. You need to use a format string in your data when data binding to the gridview. Yee examples below.
BoundField:
<columns>
<asp:BoundField headertext="CreationDate" dataformatstring="{0:dd-MM-yyyy}" //rearrange these letters as necessary
datafield="CreationDate" />
</columns>
TemplateField
<itemtemplate>
<asp:Label id="Label1" runat="server" Text='<%# Bind("CreationDate", "{0:M-dd-yyyy}") %>'>
</asp:Label>
</itemtemplate>
Try this
select cast(convert(char(11), getdate(), 113) as datetime)
SELECT convert(varchar, getdate(), 101)
OR
Declare #datetime datetime
set #datetime = getdate()
SELECT convert(varchar, #datetime, 101)
DateTime Formats
EDIT:
SQL server 2008 has this
functionality, if you can upgrade.
Just make sure to save 00:00:00 in
your table and remove time part in
Return datetime and format it in your
grid or in your code.
If you could upgrade to SQL2008, that has a separate time command.
I see you say you want to keep it as a datetime object, so as far as I can see if you can't upgrade to 2008 then you are stuck with the zeros
You can't remove time part from thr datetime datatype field.
Only thing you can do is to cast it to the date or varchar datatype before output or to set time part to 00:00:00 before insert/update.
Example:
the statement:
select cast(getdate() as date)
returns only date
What are you trying to do?
Why do you care if the database is saving the exact time or 00:00:00?
When you query this field(inside or outside the DB) you can ignore the time value and show only the date...
Again, say what you are trying to do... I believe it will be easier to help you.
Update mytable set mydatetime=convert(datetime,convert(char(10),mydatetime,103),103)
This will update your table. Hope that is what your looking for.
103: Format datetime as dd/mm/yyyy.