Insert date difference field in MS-Word - automation

I need to insert in CV created in MS Word document the age of the people.
I know the birth date of the person.
Is there a way to insert a field that will automatically calculates the age?
Johny Walker, {FIELD=NOW-BIRTHDATE} years.

This is not a 100%, but it may do:
{={ DATE \# "YY" } - { MERGEFIELD DOB \# "YY" } +
{IF { DATE \# "MM" } - { MERGEFIELD DOB \# "MM" } 1 0 }}
Use ctrl+F9 to add the {}, F9 to recalculate and alt+F9 to display the result.

Related

Adding one month to a selected date while keeping current date as default

I have a field that shows the current date and next to that is a counter where you can add one month to the current date. This was as intended, because I always want the current date to be the default one. But I would also like to allow my users to pick a different date and then count the months from that selected date. They can't do this right now. if they select a date and add one month, the date will automatically update to be todays date + 1 month.
How can I change this so that the default date is still the current date, while allowing users to select a different date and add one month to THAT date.
Eg. if today is 15/11/2022 and the user picks the 17th and adds one month, I would like the date to change to to 17/12/2022. Right now it will only change to 15/12/2022 even if the user enters the 17th.
<template>
<date-picker v-model="startDate" format="DD/MM/YYYY"/>
<b-form-spinbutton v-model="counter" min="0"/>
</template>
<script>
export default {
data() {
return {
counter: 0,
startDate: moment(new Date()).format('YYYY-MM-DD')
}
},
methods: {
populateDateAccordingly() {
this.startDate = moment().format('YYYY-MM-DD');
this.startDate = moment().add(this.counter, 'M').format('YYYY-MM-DD');
}
},
watch: {
counter : 'populateDateAccordingly'
},
}
}
</script>

Query from a table to get a JSON result

I have a table
I'd like to get the JSON result like this:
[
{
"Type":"I", //If group name is empty display ‘I’ otherwise, display ‘G’
"StartDate":"20/12/2020 8:00am", //This is the start time
"Additional":{ //Because it is non-group (GroupName is null), so Additional is an object
"Info":"having food"
}
},
{
"Type":"G", //Group by Date and Group Name.
"GroupName":"School", //If record has the same group name,
"StartDate":"20/12/2020 9:00am", //!!! Display the first entry’s start date
"Additional":[ // It is an array due to Group Name being a real value, the items in array is the record whose StartDate has the same Date value.
{
"StartDate":"20/12/2020 9:00am", //Display the start date
"Info":"Take bus"
},
{
"StartDate":"20/12/2020 9:30am",", //Display the start date
"Info":"On the beach"
}
]
},
{
"Type":"G",
"GroupName":"Class 1",
"StartDate":"20/12/2020 11:00am",
"Additional":[
{
"StartDate":"20/12/2020 11:00am",
"Info":"Restaurant "
},
{
"StartDate":"20/12/2020 13:00pm",
"Info":"Walk on Lane"
}
]
},
{
"Type":"I",
"StartDate":"20/12/2020 15:00pm",
"Additional":{
"Info":"In museum"
}
}
]
Would any one help me on this? Thank you so much.
I also attach the JSON data in this picture so the JSON format would be clearer.
There is a typo sorry, this is the new picture:
As per Microsoft SQL Server documentation, FOR JSON, will work best for you. It is supported on SQL Server 2016 and above.
SELECT CASE
WHEN GroupName is null THEN 'I'
ELSE 'G'
END as Type
,GroupName
,StartDate .....
FROM table
FOR JSON AUTO;
https://learn.microsoft.com/en-us/sql/relational-databases/json/format-query-results-as-json-with-for-json-sql-server?view=sql-server-ver15
When you form a JSON structure. Better to use with "INCLUDE_NULL_VALUES". So that it will have NULL for attribute If the value is missing.
SELECT Column1, Column2,... FROM Table FOR JSON AUTO, INCLUDE_NULL_VALUES

Can Azure Cosmos DB do this kind of query?

I have a JSON object stored in Azure Cosmos DB, and I'm seeing if there's a way to write workable queries doing basic things like Order By.
The structure looks something like :
[
{
"id":"id1",
"title":"test title",
"dataRecord":{
"version":1,
"dataRecordItems":[
{
"itemTitle":"item title 1",
"type":"string",
"value":"My First Title"
},
{
"itemTitle":"item number",
"type":"number",
"value":1
},
{
"itemTitle":"date",
"type":"date",
"value":"21/11/2019 00:00:00"
}
]
}
},
{
"id":"id2",
"title":"test title again",
"dataRecord":{
"version":1,
"dataRecordItems":[
{
"itemTitle":"item title 2",
"type":"string",
"value":"My Second Title"
},
{
"itemTitle":"item number",
"type":"number",
"value":2
},
{
"itemTitle":"date",
"type":"date",
"value":"20/11/2019 00:00:00"
}
]
}
]
I can use ARRAY_CONTAINS to find objects with a particular value, but I run into all kinds of issues if I try to sort by an the value of an object which has the title of "date".
So, as an example, I'd like to be able to say something like (pseudoish code here):
SELECT * FROM c WHERE
ARRAY_CONTAINS(c.dataRecord.dataRecordItems,
{"itemTitle":"item title 2", "value" : "My Second Title"}, true)
AND
ARRAY_CONTAINS(c.dataRecord.dataRecordItems,{"itemTitle":"item number", "value" : 2}, true)
ORDER BY < *** SOMEHOW GET THE DATE HERE from itemTitle = date ***
Then, in this simple case, I would everything returned, but ordered by date.
Obviously in the future I would be pulling out individual fields, but it's all kind of moot if I can't do the first part.
Just wondering if anyone has any great ideas.
Cheers!
You need to store the date in ISO 8601 format:
Year:
YYYY (eg 1997)
Year and month:
YYYY-MM (eg 1997-07)
Complete date:
YYYY-MM-DD (eg 1997-07-16)
Complete date plus hours and minutes:
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
Complete date plus hours, minutes and seconds:
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
Complete date plus hours, minutes, seconds and a decimal fraction of a
second
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
where:
YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)
https://www.w3.org/TR/NOTE-datetime

Alerting on sum of value of two fields in a document using Elast Alert

I want to alert on sum of two fields.
Each document will have only one of the two fields.
Ex:
{
"number1" : 30
}
{
"number2": 20
}
Above are the two documents under same index,
I want to alert if sum(sum(number1),sum(number2) in last one hour is less than some value
I have tried the below:
type: metric_aggregation
index: test-*
description: "Testing"
buffer_time:
minutes: 1
timestamp_field: "#timestamp"
doc_type: "doc"
metric_agg_key: number1
metric_agg_key: number2
metric_agg_type: sum
min_threshold: 70
alert:
- "email"
alert_subject: "FNot matching"
alert_text: |
Hi Team,s
alert_text_type: alert_text_only

mail merge conditional formatting

--Environment: Office 2007 (Word-Excel)--
I'm performing a Mail Merge into Word from an Excel table.
One of the Excel fields has a simple conditional formatting (if field1>field2 red else green).
How can I cascade the conditional formatting of that field into the word document?
thanks
I have done this long time ago where I want FieldA to be red if FieldB is 1, otherwise FieldA is normal color.
You need to Toggle Field codes and edit it. Below will use Bold. Syntax is like:
{ IF { MERGEFIELD "Field B" } = 1 { MERGEFIELD "Field A" } { MERGEFIELD "Field A" } }
{ IF { MERGEFIELD "FieldB" } = 1 { MERGEFIELD "FieldA" } { MERGEFIELD "FieldA" } }
You need to highlight the field including {...} and change the format to desired.