Lightning Flow Query - salesforce

I am creating the lightning flow. In which, I need to provide the date in the 'field1' (Type : Date) in the screen component.
In the screen component, the 'field1' should only accept the date value which is in the range of 3years in the past of the current date and 2 years in the future of the current date.
For instance, if a user is entering the value in the 'field1' Date field on 5/13/2021 then the valid date range is between 5/13/2018 thru 5/13/2023.
Can anyone please guide/assist on how to achieve this.
Thanks in advance.

enter image description here
To create this date field you need to use following formula
IF(OR(
({!Accepted_Date} <= (DATE(YEAR({!$Flow.CurrentDate}) - 3,MONTH({!$Flow.CurrentDate}),DAY({!$Flow.CurrentDate}) - 1))), ({!Accepted_Date} >= (DATE(YEAR({!$Flow.CurrentDate}) + 2,MONTH({!$Flow.CurrentDate}),DAY({!$Flow.CurrentDate}) + 1)))
), false, true
)

Related

How to modify Drupal 7 events calendar week view to include Sunday?

I'm new to Drupal 7, and I have a problem where the events calendar week view doesn't show Sunday events, because the end date in the query is incorrect. Actually it only ever shows 6 days. How can I modify the query? How can I even find where it is generated?
Below is the query from the Events Calendar (Content) page. You can see that the start date comparison is ">= '2016-11-14 00:00:00" end date comparison is "<= '2016-11-20 00:00:00'", which doesn't retrieve events happening on Sunday. I need to change it to "<= '2016-11-20 23:59:59'".
Changing the first day of the week doesn't help, because it just shifts the six day time frame to start on Sunday, and misses events on both Saturday and Sunday.
SELECT field_data_field_event_date.delta AS field_data_field_event_date_delta, field_data_field_event_date.entity_id AS date_id_field_event_date, field_data_field_event_date.delta AS date_delta_field_event_date, node.nid AS nid, field_data_field_event_date.language AS field_data_field_event_date_language, field_data_field_event_date.bundle AS field_data_field_event_date_bundle, field_data_field_event_date.field_event_date_value AS field_data_field_event_date_field_event_date_value, field_data_field_event_date.field_event_date_value2 AS field_data_field_event_date_field_event_date_value2, field_data_field_event_date.field_event_date_rrule AS field_data_field_event_date_field_event_date_rrule, node.title AS node_title, 'node' AS field_data_field_event_date_node_entity_type, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_event_cat_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_event_date} field_data_field_event_date ON node.nid = field_data_field_event_date.entity_id AND field_data_field_event_date.entity_type = 'node'
WHERE (( (DATE_FORMAT(field_data_field_event_date.field_event_date_value2, '%Y-%m-%d %H:%i:%s') >= '2016-11-14 00:00:00' AND DATE_FORMAT(field_data_field_event_date.field_event_date_value, '%Y-%m-%d %H:%i:%s') <= '2016-11-20 00:00:00') )AND(( (node.status = '1') )))
ORDER BY field_data_field_event_date_field_event_date_value ASC
I would first check your regional settings asyou can change the First day of the week there and just resave the value there - possibly try ye olde on-and-off again, switch between monday and sunday. /admin/config/regional/settings
Secondly, have you checked the module itself for this issue? A patch may be posted under their issue queue.
If all else fails, you could use hook_views_query_alter in a custom module to modify the where clause of the query that is generated. I've written a blog post on this hook previously found here but basically you have all the components of the query so can alter what you need there. Eg.
// add the condition of greater than current timestamp
$date = gmdate('Y-m-d H:i:s');
$view->query->where[1]['conditions'][] = array(
'field' => 'field_mytimefield_value',
'value' => $date,
'operator' => '>='
);

How to use INTERVAL in CakePHP 3.x

I am using CakePHP 3.x. I have converted and stored all my dates to string using the strtotime(date('Y/m/d h:i', time())); .And in DB it will store like this 1479466560 But Right now i need to select rows from exactly 14 days ago. I tried like below conditions,
$this->loadModel('Users');
$userList = $this->Users->find('all')
->select(['created'])
->where(['status' => 1,'created' => 'created + INTERVAL 14 DAY > NOW()']);
It is returning empty rows only. How to do this ?. Can any one help me !
I know this does not tell you how to use interval but it does solve the problem.
What I've done in the past is a simple >= < combination together with php variables:
$cur_date = date_create();
$date = clone $cur_date;
$date->modify("-12 hours");
$this->Model->find()
->where(['created >= ' => $date])
->andWhere(['created < '=> $cur_date]);
This effectively uses an interval. It is also nicely dynamically editable.
Your query doesn't match with any created date from your users table.
Your CakePHP3 query generated below SQL:
SELECT created FROM users WHERE (status = 1 AND created = created + INTERVAL 14 DAY > NOW())
Note: At First try and adjust above query from your phpmyadmin.
You can try below SQL for INTERVAL test
SELECT '2016-01-17 10:57:21' + INTERVAL 14 DAY > NOW();
OR
SELECT '2016-01-17 10:57:21' + INTERVAL 14 DAY;
Note: Adjust date string as you need. Now you can see what is the wrong you have done

Qlikview - Calendar - fromDate and toDate

My calendar script is loading fine but the table not reflecting any changes.
Below the code i am using:
Calendar:
load Distinct
"sDate",
Year("sShipment Date") As PostingYear,
Month("sShipment Date") As PostingMonth,
Week("sShipment Date") As PostingWeekOnly,
WeekDay("sShipment Date") As PostingWeekDay,
Day("sShipment Date") As PostingDay,
'Q' & Ceil(Month("sShipment Date")/3) As PostingQuarter
resident myTable;
Temp:
Load
min("sDate") as minDate,
max("sDate") as maxDate
Resident Calendar;
Let varMinDate = Num(Peek('minDate', 0, 'Temp'));
Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));
I create calendar object but when I pick the date I don't see change in my straight table.
I want when change start and end date to get result in my table between start and end date. Does anyone have an idea?
In your calendar properties use the field selection and use an expression.
=MonthName(sdate)
For example and then this will give you the full range to select from.
This will then reflect in your straight table.

SSIS Derived Column Replace Dates

Overview of situation: I have two databases (one is DB2 and one is MSSQL) and I am using an SSIS package to feed from one to the other via jobs. In our SQL table, datetime fields were set up as SmallDateTime (years and years ago, cannot change at this point in time yet to DateTime). We are now getting dates that are coming through as year 2099 (1/1/2099) which fails as SmallDateTime can only go MaxDate of 06/06/2079 11:59:59.
My/our solution is to use the Derived Column transform to check the date, and if it is over year 2078, make it null. It was also advised that check for null before checking date.
I tried doing this,
[Derived Column Name] [Derived Column ] [Expression]
[ MyDate ] [Replace "MyDate"] [MyDate == "" ? NULL(DT_WSTR,5) : MyDate]
[ VerifiedDates ] [Add As New Column] [VerifiedDates == YEAR((DT_DBDATE)MyDate) > = 2078 ? NULL(DT_WSTR,10) : MyDate]
But this did not work for two reasons. Not only was the expression wrong, it also would not allow me to replace the column of "MyDate" like I did in the first run. Can I not replace a column more than once? Do these tasks happen at the same time?
Due to that issue, I tried to just replace the dates via the expression
[ MyDate ][Replace "MyDate"][YEAR((DT_DBDATE)MyDate) >= 2078 ? NULL(DT_WSTR, 10) : MyDate]
as well as
[ MyDate ][Replace "MyDate"][MyDate == YEAR((DT_DBDATE)MyDate) >= 2078 ? NULL(DT_WSTR, 10) : MyDate]
But none of these seem to be the correct syntax... Can anyone point me to where I am off?
I'm also having trouble finding a good resource for the syntax, presently using this ref
Have you tried the DATEPART function instead
[ MyDate ][Replace "MyDate"][ DATEPART("yyyy", (DT_DBTIMESTAMP)MyDate) >= 2078 ? NULL(DT_WSTR, 10) : MyDate ]

Assign date in salesforce.

I have written a batch job. In this batch job i have a condition to take date > = 1/1/2012
I am not able to give the date in the query. can you please help me.
global Database.QueryLocator start(Database.BatchableContext BC) {
system.debug('Inside start');
//date mydate = date.valueof(1/1/2012);
return Database.getQueryLocator('select name from opportunity');
}
I have given it in 2 ways
1st is :
took the date into a date field and give the condition as date >= :mydate
(shows an error in debug log as Invalid date: 0 )
and
2nd way when i gave the date their itself as date >=: 1/1/2012
(it shows as error in debug log as unexpected token: / )
can you please help me
Thanks
Anu
You must follow the proper date format
YYYY-MM-DD
select name from opportunity where mydate >= 2012-01-01
More information here

Resources