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')"/>
Related
driver.find_element(By.XPATH, '//input[#placeholder="MM/DD/YYYY"]').click()
print(WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((
By.CSS_SELECTOR, '.react-datepicker__day--today'))).text)
driver.find_element(By.CSS_SELECTOR, '.react-datepicker__day--today').click()
this is part of my code, I am using it to select a date from calendar, the chosen date is "Today" this date is dynamic. Need to compare that the today date is actual todays.
Is there a way to do the comparison?
Thanks
Save web elements text as string, then convert it to date object, and compare to real date.
For example: https://www.educative.io/edpresso/how-to-convert-a-string-to-a-date-in-python
I need increase a date to smarty variable. This will not be to increase the days of a current date as smarty.now if not rather to increase the days to a order date variable.
For current date the code works:
{assign var="estimated_days" value=$smarty.now|date_format:"%u"}
{"+5 days"|strftime|date_format:"%A %e %B"}
But using this formula in to variable it not working because shows wrong dates:
{assign var="estimated_days" value=$order.details.order_date|date_format:"%u"}
{"+5 days"|strftime|date_format:"%A %e %B"}
I tried with {"order.details.order_date +5 Days"|date_format:'%A, %e de %B'} and multiple formulas and the conclusion is the right order_date only is showned with {$order.details.order_date} variable in format 10-10-2021 but when is added the |date_format the captured date is as smarty.now (current date) and not the order date.
Maybe {assign var="estimated_days" value=$order.details.order_date|date_format:"%u"} is wrong?
How can I add X days in to smarty variable {$order.details.order_date} using date_format ?
This should do the trick:
Adding a day to a variable:
{assign var="estimated_days" value=$smarty.now|date_format:"Y-m-d"}
{"$estimated_days +1 days"|strtotime|date_format:"Y-m-d"}
Smarty: current day
{$smarty.now|date_format:"%A, %B %e, %Y"}
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
How do I get just the date from a field which is labelled as for example "2015/16 Text" when I just want the date from it?
You can get the date from a string using the STR_TO_DATE() function.
SELECT STR_TO_DATE(StringColumn, '%Y/%m') FROM table
The %m and %Y are date placeholders. In the resource section of my answer you can find out more about these and which to use in your case.
Resource
Visit this page for more information
Am trying to extract month from the current date but in vain. I am using the code:
Format(Today.Date, "mmmm")
However when I try to run it to display month like January it instead displays 00. I thought that this would work but it isn't. What can I do to get the month from current date in vb.net using a simple approach like a single function?
Try This :
DateTime.Today.ToString("MMMM")
Check out This for detailed date formatting options.
try this
MonthName(Now.Date.Month(),true)
msdn: Custom Date and Time Format Strings
Format(Today.Date, "MMMM")
EXTRACT(MONTH FROM NOW()) , getting month of current date