Inconsistent output of date in controller and template - date

I'm using Symfony 5, I've entity with two date field. 1st is "date" and second is "recievedDate"
Problem is while displaying date in a loop "{{ record.date | date('H : i')}}" in a datatable, the twig display correct hours for field date and display 00.00 as hour for the second field date witch is recievedDate and it is not correct.
Same problem with another entity having only one field date. Again twig display 00.00 witch is not correct. If I do a foreach in my controller and dump the date the hours are correct. Strangely when i send the collection to the twig and display hours then it show wrong hour 00.00
Twig screen shot of dump date in the loop (get with findAll function)
Normally it should show 8:50. There is not problem while showing display the entity outside of loop in a another page get with find(id) function
And here is an example when I dump date and recieved date in the loop

I figured out that the problem was somewhere else
Actually, I have function inside of my entity class that calculates the day interval passed. So this function take the date and set hour to 00.00.00 and do calculations.
Thats why in that list hours was always showing 00.00.00
The solution was to clone the date
so instead of :
$start_date = $this->getDate()
I used this :
$start_date = clone $this->getDate()

Related

DAX and FORMAT function

i have a field for date with date, month and year.In my visualization, I need date to be displayed in (MON-Year) format.
I switched to data view, created calculated column with
Mon-Year = FORMAT('table'[Date],"YYYY-MM")
Now it's getting displayed as (YEAR and Month number) but I want to change it as month name.
After changes in data view, when I close apply, the column is present but there is no data type visible.
Should I create different calculated fields for year and month separately and then concatenate it?
any help would be appreciated.
If you want month first, then maybe you should specify it that way.
Mon-Year = FORMAT('table'[Date],"MMM-YYYY")
This may be useful for you:
https://learn.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function

How do I set the date to always read last Saturday in Tableau?

I do weekly reporting in Tableau and each page is labelled to say data is pulled through every Saturday (Image below).
My question is if there is a way to program that date to update every week on its own, without having to manually do it for every page on a 52 page report?
I'm not looking to update any data fields, just that label for each page.
See the below link on how you can pull in the last data refresh date:
http://kb.tableau.com/articles/howto/adding-data-refresh-time-stamp-to-view
Or you could have one calculated field that hold this date and add it to every page/view. Then you just have to update one field which will update every view.

Crystal Reports default value for parameter

I'm attempting to make the parameters for a Crystal Report more user-friendly for a client, who has requested that they be able to have the default values for a Start and End date parameter be the first and last day of the previous month.
I know how to use either a formula in CR or a stored procedure to produce these values, but I want to know if a variable can be used in the 'Default Value' setting for a parameter, or if it only allows for static entries. Does anyone know? Right now the user can set the date parameters to null and the stored procedure generates the data for the previous month on its own, but I thought it'd be nice if the date parameters actually displayed the dates that were being used as defaults. Thanks in advance!
You can do it, Try below process:
Create a parameter ?date with String datatype and take static and write two default strings as below:
First day of previous month
Last day of Previous month
Now go to record selection formula and write below code:
if ({?date}="First day of previous month") then
table.date=DateSerial(year(currentdate),Month(Currentdate)-1,1)
else if ({?date}="Last day of previous month")
then
table.date=Cdate(DateAdd("d",-1,DateSerial(year(currentdate),Month(Currentdate),1)))

Tableau Using Parameters for a Date Selector

I've been looking into making a date selector so instead of filtering by Month, Week by adding filters then displaying the quick filters to correspond. I want to be able to dynamically change the date so I can choose between Quarter, Month and Week in a single drop down.
I have made the selector part no problem it shows but when I come to my calculated field, it's not behaving how I would like.
Here is my calculated field:
CASE [Parameters].[Date Select]
WHEN 'Quarter' THEN QUARTER([Date])
WHEN 'Month' THEN MONTH([Date])
WHEN 'Week' THEN WEEK([Date])
END
This gives 2 errors...
Unknown Function QUARTER called
Unknown Function WEEK called
I am puzzled because the month one is fine.
Normally in tableau to get the month/quarter/week, I click on the Date dimension and select Month or week and it filters and displays like so: MONTH(Date).
Can anyone tell me where I'm going wrong and how I can pull the week and quarter from date in the calculated field so my selector will work.
Thanks.
There are no QUARTER and WEEK functions in Tableau, as you can see in the image below.
What you should be using to get these values are:
DATEPART('quarter',[Date])
DATEPART('week',[Date])
For filtering the date using your parameter as filter, I'll assume that you want to filter the current quarter, month or week. In this case you'll need to setup your paramaters like this:
Then you'll create a Calculated Field with the following formula:
DATEPART([Date Selector],[Date]) = DATEPART([Date Selector],TODAY())
This should give you a True/False dimension which you will use as filter for the value True. After that you should have a working parameter filtering your data accordingly to the value set.

Need a PDF with multiple current date fields

I have a checklist form I'm building in Adobe LiveCycle ES2 that our IT department uses and they need it to have Monday-Friday on it and each day needs to have a current date field that autofills and becomes read only once it is populated, but it only needs to populate that day. Basically, on Monday, they open the form, the date for Monday gets populated, but Tuesday-Friday stays empty, they come in on Tuesday and open the form and Tuesday's date is now also populated. Does this make sense? Is this something that is fairly simple? Thanks!
I am not sure whether I know exactly what you really want to achieve. If I made some wrong assumptions let me know.
You can get week day using getDay() method on JavaScript Date object. It returns int value 0-6 where 0 means Sunday, 1 Monday, .. 6 Saturday.
Assume you have one Date/Time field for every week day. To make it read-only set their type to protected (in Object->Value toolbox). In each of them put the following code in initialize event. Don't forget to adjust if condition for every field
var d = new Date();
if (d.getDay() == 6){ //checking whether today is saturday
this.rawValue = util.printd("yyyy-mm-dd", new Date());
}