EXTJS 7 Editable Grid, Select date in datefield, wrong dateformat in column - extjs

I have the problem with a editable grid. in the grid there is a datecolumn. if i change the value with the datefield to 23.12.2022 for example and save the row. the server saves it correct but in the gridcolumn i get the dateformat "fri dec 23 2022 00:00:00 GMT+0100". where is my problem? i cant find any solution that works. i tried it with in the data model i tried some in the datefield like submitformat. i always got the gmt string and not the well formated date d.m.Y in the columnfield. has anyone an idea?
I explained it wrong! I have an editible grid with an column (the column is just a string field because it can contain different values like date,number) with different editfields. when the datefield is active and i edit the value of this column with a datefield i always geht the gmt date string. its not possible for me to format this datestring

In your datecolumn, specify the format, like:
columns: [
{
text: 'Date',
dataIndex: 'date',
xtype: 'datecolumn',
format: 'd.m.Y' //This is the format that you want
},
// other grid columns
]
You can check more date formats at: https://docs.sencha.com/extjs/7.0.0/modern/Ext.Date.html

Related

Ms sql output in date format

I have a requirement. I have datetime field and I want data in datatype=date
Existing date: 2019-11-13 00: 00: 00: 000 ; datatype=datetime
Expected output require: 11/13/2019 (mm/dd/yyyy) ;
datatype= date
Please help me.
If the core requirement is a right type then:
SET DATEFORMAT MDY;
SELECT CAST(GETDATE() as DATE);
Explicit DATEFORMAT added becaise the output depends on a language settings, so can be yyyy/mm/dd or mm/dd/yyyy, some apps can be sensitive to this, as example SSRS.
However, if there is still a requirement to get value in a precisely right format on a database side, then consider to use a FORMAT statement:
SELECT FORMAT(GETDATE(), 'MM/dd/yyyy')
I have datetime field and I want data in datatype=date
If you want the data type as DATE, in that case you can try like following.
SELECT CAST(YourDateTimeColumn AS DATE) from [YourTable]
Formatting part you should be doing in UI.
You can use CONVERT() :
SELECT t.datecol, CONVERT(VARCHAR(10), t.datecol, 101)
FROM table t;
Your desired date format requires varchar type, if you want date only then you can do instead :
SELECT t.datecol, CONVERT(DATE, t.datecol)
FROM table t;
If you don't want to convert the type, then these type of conversation should do in presentation layer instead.

Convert varchar to datefield in SQL Server

I am aware that this is a very common and have tried using the solutions suggested on similar questions. However, I cant seem to make it work.
I have a column which contains dates, but it is of varchar datatype.
The data looks like this:
startdate
-----------
15/01/2007
29/06/1998
07/12/2001
and so on..
I tried the following command
try_convert(datetime, startdate) as 'startdate'
But it returns a lot of NULLs even when there is a date populated in the original column.
Can someone please help?
The try_convert method accepts three arguments: Data type, Expression, and Style.
You need to use the Style argument:
try_convert(datetime, startdate, 103) as 'startdate' -- 103 is dd/MM/yyyy
(a list of supported styles can be found here)
Also, You should store date values as Date, not as varchar.
For more information, read Aaron Bertrand's Bad habits to kick : choosing the wrong data type

SSRS Format string to date time DD MMM YYYY HH MM

Display in reporting services text box - data is grouped.
Best way to format grouped data 20170518110610 to DD MMM YYYY HH MM?
I.e.
18 May 2017 11:06
Tried Text box properties - number - custom format - dd-mmm-yyyy hh:mm the result is the same 20170518110610
You have problems because 20170518110610 is a varchar. You need to convert it to date before format it.
Possible solutions:
1) Return a datetime not varchar from datasource (preferred)
2) Parse value in SSRS then format value:
=Format(DateTime.ParseExact("20170518110610", "yyyyMMddHHmmss", Nothing), "dd-mmm-yyyy hh:mm")

SQL select HTML5 datetime-local

Using a datetime-local form field, and inserting its value into a SQL 2014 smalldatetime field. When querying the database to populate the form field for editing, I'm using
SELECT FORMAT(myDate, 'yyyy-MM-ddThh:mm:ss') AS myDate
My form field code is:
<input type="datetime-local" name="myDate"
id="myDate" required
value="<cfoutput>#myDate#</cfoutput>">
When populating the above form field with this database value, it returns the correct date and time BUT it always indicates AM. EXAMPLE: the value in the database table is
2016-11-03 13:09:00 but the value in the form shows as 11/03/2016 01:09 AM
How can I change my SQL format to accurately populate the form field? It should be 11/03/2016 01:09 PM?
Thanks
I would leave the formatting in the front end. However, if you change the hours to uppercase it will give you the time in 24 hour format.
SELECT FORMAT(myDate, 'yyyy-MM-ddTHH:mm:ss') AS myDate

database field with type timestamp is not updating

Duplicate of database timestamp value is not
updating
I have a variable which contains the date and time in 0000-00-00 00:00:00 format but when i put this variable in database field with type timestamp .. it is still 0000-00-00 00:00:00
Make sure that you are using the right format of the datetime. Mysql default datetime format is YYYY-MM-DD H:i:s. But, it seems that you are trying to insert the datetime value with the format of (YYYY:MM-DD H:i:s). It does not allow to insert the datetime value, so the inserted value becomes 0000-00-00 00:00:00.
Try by changing your calendar format to (YYYY-MM-DD H:i:s). I assume that you are using datatime datatype for the Valid_till column. Click the below to know more about mysql data structure.
Mysql Date format

Resources