I have an issue with SOQL within a query activity in Salesforce Marketing Cloud Automation Studio.
I want to update null values with birth dates of users in a column named "date of birth" that includes birth dates of a ton of users with datatype = date.
I want to update this column, "date of birth", based on another column named "date of birth 2" which also includes birth dates of a ton of users but instead with datatype = string.
Thus, my goal is to be able to update only the missing date fields in the column "date of birth" leveraging data from the column "date of birth 2".
With my current very simple code (see img 1/2), I either update nothing in the data extension (when the WHERE column = NULL is added, see img 2) or I update the null values but also overwrite the existing date values in the data extension (when there's not added a WHERE column = NULL, see img 1). I wonder if it possible to simply update the null fields and let the currently filled fields stay?
Looking forward to hearing from you and please tell me if my query is unclear!
So I think you can query on the object where your (date of birth) field is equal to null and (date of birth 2) is not equal null.
SELECT (date of birth),(date of birth 2) FROM objectName WHERE (date of birth) = NULL AND (date of birth 2) != NULL
Please make sure your (date of birth 2) field must be in YYYY-MM-DD format.
Sample code.
List<objectName> li = [SELECT (date of birth),(date of birth 2) FROM objectName WHERE (date of birth) = NULL AND (date of birth 2) != NULL];
for(objectName o : li){
(date of birth) = Date.valueOf((date of birth2));
}
update li;
Related
I have a data source that has four different dates associated with each matter- open date, close date, created date, and modified date. I want a scorecard to display the total number of matters that we "worked with" in a set date range, which includes matters that any of those dates are in the correct range for.
I essentially want this:
SELECT COUNTUNIQUE(ID)
WHERE ((openDate >= Date1 AND openDate <= Date2)
OR (closeDate >= Date1 AND closeDate <= Date2)
OR (createdDate >= Date1 AND createdDate <= Date2)
OR (pendingDate >= date Date1 AND pendingDate <= Date2))
Date1 and Date2 should be selected by the viewer in a control.
I have a control that filters by one of the dates, but I'm struggling to find a way to combine all 4 dates using an "OR" operator. I've tried using filters, metrics, and parameters but I haven't been able to get any working properly. Is there a way I can apply a SQL query similar to the one above to a scorecard?
Any ideas/advise is much appreciated!! I'm new to Data Studio so still getting a feel for how it all works. Thanks so much!
If the data source is Big Query, a custom query can be used and use in the where statement #DS_START_DATE and #DS_END_DATE.
Otherwise you need to blend the data with itself for each case.
Use the id to join the data set together. Use for each case the data field and add a metric id_1 , id_2 ... with the formula 1.
Then add a chart and a metric field:
case
when id_1 is not null then id
when id_2 is not null then id
else null end
I am creating an SSRS report where I need to have a parameter called Status and the values would be "Current", "Former", or basically selecting both of them in terms of display both Current and Former.
This parameter will reference a date column and if the (date is NULL OR date > GETDATE()) then they would be considered "Current"
If (date is not NULL AND date < GETDATE()) then they would be considered "Former"
I've tried using in the WHERE clause (WHERE DATE #NULL OR DATE > GETDATE()) and similarly with the "Former" parameter value, but I am not sure if in SSRS if it's possible to pass the IS NULL and IS NOT NULL to these parameter values.
Sample of table data:
Name Date
John NULL
Bill 2/27/2021
Bob 2/1/2021
So in this example, John is "Current", Bill is still "Current", and Bob is "Former".
I think what you're looking for is this:
WHERE (#param = 'Current' AND (Date is NULL OR date > GETDATE()))
OR (#param = 'Former' AND Date <= GETDATE())
OR #param = 'All'
As jarlh said, you don't need to check for "is not null and less than" in the second line.
Not sure what you meant by "basically selecting both of them" so I assumed a third option for "all". If the parameter being null triggers that instead, you should be able to change the last line to:
OR #param is NULL
Then "NULL IS NULL" would satisfy the third condition and bring back all rows.
I have a table in dataverse, that has a date, telephone number, and ID columns as below.
Date
ID
Telnum
12/6/202
abcd
8421678
12/9/2020
abce
8421679
12/13/2020
abcg
8421678
From the table the 1st and 3rd column have the same Tel num, but different dates and ID. What am trying to achieve is on the same table in a column called end date,post the last date with regards to the tel num this is basically the 1st date of the date the number switched to a new record based on ID.
The table am trying to come up with looks as below
Date
ID
Telnum
Date To
12/6/202
abcd
8421678
12/13/2020
12/9/2020
abce
8421679
12/13/2020
abcg
8421678
What I've tried is create an Instant flow, List Records(The table name), List records 2 (Table name but this tome with filters {The filters are (tel num eq tel num and id ne id)}, Then Update record to populate the end date.
What am missing is a step to get the max or latest date of the column that I will append to the date to mapping.
Any idea on how to achieve this will be highly appreciated.
TIA.
According to the description of your requirement, it seems you want to add one more column(named Date To) for the table and set the current date(you mentioned as max or latest date) as the value of the new column.
The second table you provide shows the value of DateTo should be like 12/13/2020, but if you just set the date with the format month/day/year, it can't help you distinguish the two records which has same Telnum because they are both 12/13/2020. So you should set the value of DateTo with format of 2020-12-21T07:23:34.5951356Z. To implement it, you can use utcNow() method shown like below screenshot.
If I misunderstand your requirement, please let me know and provide more details about your question.
I need to select from a table that has two fields , a start date and an end date , selecting the row that the current date is. Look at the image ...how do i select the row that encompasses the date range 91/201 - 9/15/2018 ? Somehow this was flagged as a duplicate. I am NOT attempting to find overlap. I am attempting to find the row that represents a given date. Say , one table has a field that has the value 9/5/2018 ....how do I select the row that has a start date of 9/1/2018 and end date of 9/15/2018
I have this code in a stored procedure:
d01072016 = case when '07-01-2016' between pp.committedstart and pp.committedend then 'y'
when '07-01-2016' < pp.committedstart then 's'
when '07-01-2016' > pp.committedend then 'g' end
based on the date it updates a particular column.
Now I want to compare only date and month so that it becomes year independent.
The date format in SQL Server is mm-dd-yyyy and the table column name is like dd-mm-yyyy but I can always this table column name to match to mm-dd-yyyy.
Please help.