Changing a date format from m-d-y to y-m-d in jinja - jinja2

I want to use the value - 01-01-1990 and format it to 1990-01-01 i'm trying to use the
strftime filter but i think im missing something

Related

Converting Date to String and then to Date again in mysql .Combining 2 functions in mysql

have column which is of type date having default format as YYYY-MM-DD. I want to get date in format DD-MM-YYYY but as date type only. I would like to know how is it possible? I am combining 2 functions together as shown below but i am not getting the desired result
STR_TO_DATE(DATE_FORMAT(emp.doj, '%d-%m-%y'),'%d-%m-%y') as doj
Please dont close this questions as its a different one not asked before thanks!!!
DATE_FORMAT(emp.doj,'%d-%m-%Y') as doj
You have not need to use STR_TO_DATE. use only DATE_FORMAT. It should be work.

check date in laravel for an output

It seems to be a bit different in Laravel as in CodeIgniter if you want to check a date.
My variable anniversary has the type date in my database. In the most columns I still have 0000-00-00.
In case a date has 0000-00-00 I want that it will doesn't shown. How can I check this?
At the output of 0000-00-00 I get the following result -0001-11-30 00:00:00 and don't understand it.
You could use PHP DateTime to convert your dates. Reference here
$anniversary = new DateTime('2016-02-10');
$anniversary->format('Y-m-d H:i:s'); //Whatever format you wish to get
For a full reference about the format, you can look here.

What transformer can I use to put a date into YYYY - MM - DD format with no time format in final result?

I just started using webMETHODS today and need to transform a date input value that comes in like this.
Example:
yyyy-mm-dd hh:mm:ss:hh
I need just the date portion of this variable and am currently using pub.date:formatDate which will crash my flow service.
What should I be using?
An alternative would be to use pub.date:dateTimeFormat, which allows you to set an input pattern, for example dd.MM.yyyy hh:mm:ss.
pub.date:formatDate is used to convert a date input to a string output based on a string pattern.
Here you are trying to convert a string input to a string output.
You have to do the following:
a.
First convert the string (Process_date_orig_str) to date format (Process_date_dt)
b. Then use the date (Process_date_dt) to the required string format using pub.date:formatDate to get (Process_date_new_str)
Note: You will have to create your custom java service to convert string to Date.
I played around with this for practise. The 'correct' answer is what Christian Strempfer posted - this is what pub.date:dateTimeFormat is meant to do: transform beween datetime string formats. I'm not sure about your date pattern though - try currentPattern=yyyy-MM-dd HH:mm:ss.SS and newPattern=yyyy-MM-dd
A 'good hacky approach is using pub.string:subString (positions 0 and 10) to simply hack the end off the input string. You can also try regexs -- pub.string:replace, useRegex=true, searchString=^(.{10}).*, replaceString=$1. (searchString=^(.{10}) should also work, but it doesn't)

how do I convert date type to hh:mm in mysql?

I got in my table two types:
hour_Event in type date
date_Event in type datetime
I would like hour_Event to be formatted to hh:mm
and date_Event to be dd/mm/yyyy
I use PHPMyAdmin and im new with MySQL so I dont know how to change the format and for what.
How do I do it?
**DATE_FORMAT(hour_Event,'%h:%i')** will give you hour_Event in hh:mm
and
**DATE_FORMAT(date_Event,'%d/%m/%Y')** will give you date_Event in dd/mm/yyyy
You could change the format using php before you insert data or after retrieving themfrom your database according to your needs.You could use DateTime / strtotime() & date(). In most cases a single timestamp field in your table is enough for an event.
Have a look here:
Convert one date format into another in PHP
Also you could format your field according to your needs with mysql for example:
DATE_FORMAT(tables.field, '%d-%m-%Y %H:%i:%s') AS 'new_name'
Have a look about it here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

Converting date format using str_to_date

In one of my Mysql database table the dates are stored in the format 31-Jan-05.
I'm trying to convert this format to 2005-01-31 before inserting them in other tables.
I've tried in this way str_to_date(exam_date, '%d%M%Y'), but i encounter the following error
Incorrect datetime value: '31-Jan-05' for function str_to_time
Can't i change the date format from 31-Jan-05 to 2005-01-31 using str_to_date?
Thanks in advance.
Yes. But you have two problems.
The second parameter is the current date format. (i.e. of the string)
You need to have the proper format (i.e. %b instead of %M).
Read the docs the for str_to_date().
str_to_date(exam_date, '%d-%b-%y')
Note: If you don't have a zero padded day, then you need to use %e instead of %d.