Backgrid wont render date values from database - backbone.js

Im new to backGrid and im very impressed with what it can do so far.
I have successfully got some data from my Database back to my web-app in JSON and all renders ok with the exception of a date column which will throws an error:
Object 1361561820000 has no method 'trim' Heres is the column:
var columns = [{
name: "dateTime",
label: "Date/Time",
cell: 'date'
}];
This will render ok on the page when cell is set to 'string' but obviously this doesnt display in date format..
Is there anyway around this?
Previously i used a standard html table and parsed the date column with: $.format.date(get('dateTime'), 'dd/MM/yyyy hh:mm:ss' but i seem unable to apply this now,
Any help much appreciated

All of the core datetime cells will only accept datetime values in ISO-8601 format. Timestamps are not supported. To make the datetime cells to accept UNIX timestamps, you will have to override the formatter.

Related

ADF - Change the date format from any format coming from csv to yyyy-MM-dd HH:mm:ss while loading in target sql table taking datetime

I have a situation where I am getting dates in two separate formats, MM/dd/yyyy & yyyy-dd-MM, AND there might be even more different formats as well in csv which will be obviously in string.
Below are the data which currently come as String from CSV-
1/14/2022 0:00
2021-12-31 00:00:00
I am using a Dataflow task in ADF to load the data into Azure SQL where the default format it uses should be yyyy-MM-dd HH:mm:ss.
how can I do this?
ok, i managed to build a quick demo.
Main idea of my solution:
you need to differentiate between valid rows and rows that needs to be modified.
in order to do so, i used case condition.
the idea is to add a derived column with a name 'Date' and modify only needed rows.
Input Data:
i created a csv file and saved my data as a dataset in ADF.
ADF:
In source, i select my dataset as an input.
in a derived column activity:
added a new derived column with a name 'Date' , value :
case(contains(split(Date,''),#item=='/'), toString(toTimestamp(Date,'MM/dd/yyyy H:mm'),'yyyy-MM-dd HH:mm:SS'), Date)
in toTimestamp method, i added first the dateFormat of my input Date and in toString the desired format that i want to cast the date to it.
Output:
P.s
You can cast all possible date formats that will appear in your data in that way.
you can read more about it here:
https://learn.microsoft.com/en-us/azure/data-factory/data-flow-expressions-usage#toTimestamp

SSRS report - export to excel date time filteration

Populating an SSRS report from dyanmic dataset i.e. number column and order of columns may vary based on condition, and this report on trying to export to excel. But in exporting date column filtration not working. Finds the reason is I bind the column in string format.
Sample data format to understand. Here the columns & order of columns may vary as per condition.
And I am converting this to below format and passing to SSRS as dataset.
And populating report by grouping with ROW_NO & COL
Then I tried to convert DOB column to date time.
For converting DOB to date format changed return type of DOB from sql query as datetime, converted column value to date time using CDate() in SSRS and formatted in own format (dd-mmm-yyyy).
Below expression used for converting to date time:
IIF((Fields!COL.Value="DOB") ,CDate(Fields!VALUE.Value),(Fields!VALUE.Value))
But showing #Error for columns data type other than date time:
Go to your detail textbox in the DOB column. And use the following expression:
=Format(CDate(Fields!DOBValue.Value), "dd-MM-yyyy")
This way the date in your DOB column will show 23-01-2018
Note: The expression just works if in the Fields!DOBValue.Value field are just dates. If there is a N/A it will throw an error. Then you have to clear the N/A first.
And if you want to export it to Excel you need to set the language in your report properties (use your region) and go to your textbox where you wrote in the above expression under Textbox properties > Number chose Date format.
UPDATE
Based on your updated question I think I found the error. The problem is your writing of the month names combined with the report language. My report language is set to DE. For me the following works:
=CDate("15-Mai-94") 'Result 05.05.1994
But this dosent work:
=CDate("15-May-94") 'Result =Error
The second one works, when I set the report language to EN but then the first one throws an error

ExtJS 4, how to filter date/time columns to an entire day?

In an ExtJS grid I am looking for the optimal way to implement a date(day = x) filter on a field that is date with time.
The stock filters work for Before and After but the On filter does not because a date never equals a date time. EG: "01-01-2018 <> 01-01-2018 14:10:10" A date time filter is too specific as I want the entire day's data. What is the best way to implement a grid filter so that the On selection will match against all timestamps on that day regardless of time but still display the date with time? My data is a postgresql timestamp without time zone..
My current fix is to manually convert eq filters to date ranges on the server side but that does not scale well and is likely to create regression errors.
Also I am paginating so I have to filter remotely.
Extjs 4.2 with Cakephp 2.
I am using the following approach to group a grid by the date, but it should help in your case as well: I add to the model a new field that derives from the original field, and then I group (or you filter) by that field.
[{
name: 'StartDate',
type: 'date'
},{
name: 'StartDateOnly',
convert: function(v, rec) {
return Ext.Date.clearTime(rec.get("StartDate"), true);
}
},{

st-sort doesn't work on date column

I am using smart table for my angular project. I am facing an issue for sorting a table column which has Date type data. I get the column info in milliseconds which i convert to Date type. It works as it is when date doesn't have any formatting applied. However, if i apply formatting to make it more easily readable, the sorting doesn't work properly, half the data is sorted and other half is not.
How can I sort Date type column if i want to apply formatting as well?
Here's the code snippet of what I have tried so far
for(var i=0; i<$scope.rowCollection.length; i++)
{
$scope.rowCollection[i].ltime =
(new Date($scope.rowCollection[i].lastRegisteredTime )).toLocaleString();
$scope.rowCollection[i].rtime =
(new Date($scope.rowCollection[i].registeredTime)).toLocaleString();
}
In this, lastRegisteredTime and registeredTime are data in milliseconds. If I just convert the data to Date without toLocaleString(), sorting works. But, it is little difficult to read the information for users as I want to show the time information as well.
Any help is appreciated.
Thanks
Since toLocaleDateString returns a string, you cannot sort by ltime as if it were a real date object. I suggest you leave the field as date object and then use date filter in views, where ever you wish to display the date.
<span>{{row.ltime|date:'YYYY/MM/DD'}}</span>
or
<span>{{row.ltime| date:'fullDate'}}</span>

AngularJS layered date filter for database submission

I am having trouble with date submissions to a database. When date and time are both needed, I parse the values from the database as a timestamp, which gives me the value of the date and time in milliseconds since 1970. Using the AngularJS date filter, I am able to display the value in a user-friendly way.
$filter('date')(1380292078000, 'MM/dd/yyyy hh:mm a'); => 09/27/2013 10:27 AM
But this format as a timestamp when I send the value back to the database, my code throws an error. The database wants the date to be displayed in a different format.
java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss
So I add a second filter to convert the value date representation of the millisecond count (the user might have changed the value), but I am just getting a clone of the first date representation.
$filter('date')('09/27/2013 10:27 AM', 'yyyy-mm-dd hh:mm:ss') => 09/27/2013 10:27 AM
Here is a link to the fiddle I wrote to test this. Are we not able to stack filter conversions on top of each other? I had a thought to convert the first conversion result into milliseconds to use as a source for the second conversion, but I didn't see a method to accomplish this in the date documentation. If that would be the only solution, though, I am sure I could whip something up. Because Java has mostly deprecated functions to work with dates, I feel it would be simpler to handle this on the Javascript/AngularJS side.
The date filter will only work with a JSON date string (see source).
You can get around your problem by converting to a date object:
$scope.date2 = $filter('date')(new Date($scope.date), 'yyyy-MM-dd hh:mm:ss')
See updated fiddle
However... You should be validating and formatting this input on the server side. You can't trust data coming from a javascript application to be in the correct or expected format. I'd recommend just posting back $scope.date and allowing the server to format in your database format. By doing the yyyy-MM-dd hh:mm:ss formatting on the client-side, you're tightly coupling your user interface to database implementation and that's generally considered a bad idea.

Resources