I haven't found anything for this yet.
I am using Ansible and I'm trying to change some values after a decent amount of time.
But my problem is I get a value like:
2020 Nov 19
But I need it to be like:
2020 11 19
How can I do this?
using to_datetime and strftime you can achieve it. the filters to apply would be:
"{{ '%Y %m %d' | strftime(( my_date_string | to_datetime('%Y %b %d')).strftime('%s')) }}"
as reference, please see the examples here. The idea is to convert your string value to datetime using the to_datetime, then to epoch time using strftime, and finally reformat that to your desired YYYY MM DD.
A PB with 3 example dates:
---
- hosts: localhost
gather_facts: false
vars:
my_date_examples:
- "2020 Nov 04"
- "2020 Apr 11"
- "2020 Aug 23"
tasks:
- name: reformat date string
debug:
msg: "{{ '%Y %m %d' | strftime(( item | to_datetime('%Y %b %d')).strftime('%s')) }}"
loop: "{{ my_date_examples }}"
output:
TASK [reformat date string] *******************************************************************************************************************************************************************************************
ok: [localhost] => (item=2020 Nov 04) => {
"msg": "2020 11 04"
}
ok: [localhost] => (item=2020 Apr 11) => {
"msg": "2020 04 11"
}
ok: [localhost] => (item=2020 Aug 23) => {
"msg": "2020 08 23"
}
cheers
Related
If this json output looks like this
{
"Bank_Name":"This is bank name",
"ACC_Name":"Tummy",
"ACC_No":"1122XXXX115",
"Date_Active":"Jan 31 2019 2:16PM",
"Date_Expired":"Nov 17 2020 1:14PM",
"Bank_Status":"Expired",
"email_Notif":[
{"Verification":[{"User_Email":"tfe.master#gmail.com","Send_DateTime":"2020-11-03T13:30:59.7036152"},
{"User_Email":"the.user#outlook.com","Send_DateTime":"2020-11-03T13:31:02.1563596"}]
},{"Verified":[{"DateTime": "2020-11-03T13:31:02.1563596"}]
},
{ "Updating":[{"User_Email":"the.spv#gmail.com","Send_DateTime":"2020-11-03T13:30:59.7036152"},
{"User_Email":"the.officer#outlook.com","Send_DateTime":"2020-11-03T13:31:02.1563596"}]
}
],
"rejection_Statuses":[
{"Verification":"Nov 3 2020 01:31:02 PM"} ,
{"Verified":"Nov 7 2020 01:12:03 PM"} ,
{"Updating":"Nov 17 2020 01:18:03 PM"} ,
{"Re_run":"Nov 27 2020 05:18:03 PM"}
]
}
Questions:
How do I use "JSON_Modifiy" in SQL Server to insert email_Notif (as object of array) ? if JSON input looks like this:
{"Bank_Name": "BPD SULAWESI SELATAN",
"ACC_Name": "Tutik",
"ACC_No": "1122000115",
"Date_Active": "Jan 31 2019 2:16PM",
"Date_Expired": "Nov 17 2020 1:14PM",
"Bank_Status": "Expired",
"rejection_Statuses":[
{"Verification":"Nov 3 2020 01:31:02 PM"} ,
{"Verified":"Nov 7 2020 01:12:03 PM"} ,
{"Updating":"Nov 17 2020 01:18:03 PM"} ,
{"Re_run":"Nov 27 2020 05:18:03 PM"}]
}
How to get value from "email_Notify" as JSON format in SQL Server query by using select statement ? (Verification, Verified and Updating)
If I understand correctly, one way to achieve this is:
JSON:
DECLARE
#email_Verfication nvarchar(max) = N'{
"Verification":[
{"User_Email":"tfe.master#gmail.com", "Send_DateTime":"2020-11-03T13:30:59.7036152"},
{"User_Email":"the.user#outlook.com", "Send_DateTime":"2020-11-03T13:31:02.1563596"}
]
}',
#email_Verified nvarchar(max) = N'{
"Verified":[
{"DateTime":"2020-11-03T13:31:02.1563596"}
]
}',
#email_Updating nvarchar(max) = N'{"Updating":[
{"User_Email":"the.spv#gmail.com", "Send_DateTime":"2020-11-03T13:30:59.7036152"},
{"User_Email":"the.officer#outlook.com", "Send_DateTime":"2020-11-03T13:31:02.1563596"}
]
}',
#detail NVARCHAR (MAX) = N'{
"Bank_Name":"BPD SULAWESI SELATAN",
"ACC_Name":"Tutik",
"ACC_No":"1122000115",
"Date_Active":"Jan 31 2019 2:16PM",
"Date_Expired":"-",
"Bank_Status":"Active",
"rejection_Statuses":[
{"Verification":"Nov 3 2020 01:31:02 PM"},
{"Verified":"Nov 7 2020 01:12:03 PM"},
{"Updating":"Nov 17 2020 01:18:03 PM"},
{"Re_run":"Nov 27 2020 05:18:03 PM"}
]
}'
Modify JSON:
SET #detail = JSON_MODIFY (#detail, 'append $.email_Notif', JSON_QUERY(#email_Verfication, '$'))
SET #detail = JSON_MODIFY (#detail, 'append $.email_Notif', JSON_QUERY(#email_Verified, '$'))
SET #detail = JSON_MODIFY (#detail, 'append $.email_Notif', JSON_QUERY(#email_Updating, '$'))
Parse JSON:
SELECT j2.[key], j2.[value]
FROM OPENJSON(#json, '$.email_Notif') j1
CROSS APPLY OPENJSON(j1.[value], '$') j2
I am using Angular6.
Below is the ngfor with div. Here the api outputs the meeting date and time with status. Normally the status is upcoming.
If the date time is 09/18/2018. and Time is 5.30 Pm.
<div class="col-sm-12" *ngFor="let todayinfo of todaylist | paginate: { id: 'todaypage', itemsPerPage: itemperpage, currentPage: page, totalItems: todaytotal}">
<div class="meeting-date-time" title="Date Time" >
{{todayinfo.meeting_date | date: 'MMM d, y '}} <br>{{todayinfo.displayTime}}
</div>
<div>{{todayinfo.status}} </div>
</div>
The upcoming status should be changed as Join, before 15 minutes of the meeting time.
i.e at Sep 18 at 5.15pm the content need to change as Join. Here how to check the date time check condition. It is displayed inside the loop. If there is any click action we will check this with separate function. Without any events how to check the date time condition here?
Now the Output is
Sep 18 2018 5.30 PM --- Upcoming
Sep 4 2018 9.00 AM -- Completed
Spe 17 2018 7.15 PM -- Upcoming
These upcoming need to change to Join before 15 min of the corresponding date time.
There is simple solution how you can achieve that:
const meetings = [
{meeting_date: new Date(2018, 8, 17, 11, 44), status: null},
{meeting_date: new Date(2018, 8, 17, 12, 45), status: null}
];
const today = new Date();
meetings.filter(meeting => (meeting.meeting_date.getTime() - today.getTime()) <= 900000).forEach(meeting => meeting.status = 'Join');
It will check for meeting where time difference is less or equal to 900000(15min) and mark their status as 'Join'.
How can I convert month to string in ionic 2 using Pipe? given the sample data below:
In my .ts file
let users = [
{
user: "A",
birthDate: "2017-08-01"
},
{
user: "B",
birthDate: "2017-08-02"
},
{
user: "C",
birthDate: "2017-08-03"
},
{
user: "D",
birthDate: "2017-08-04"
}
]
In my .html file
<ion-list>
<ion-item *ngFor="let user of users">
<div>Name: {{user.name}}</div>
<div>Birth Date: {{user.birthDate | date: "MM dd, yyyy"}}</div>
</ion-item>
</ion-list>
The sample output will be
Name: A
Birth Date: 08 01, 2017
Name: B
Birth Date: 08 02, 2017
Name: C
Birth Date: 08 03, 2017
Name: D
Birth Date: 08 04, 2017
Expected output will be
Name: A
Birth Date: August 01, 2017
Name: B
Birth Date: August 02, 2017
Name: C
Birth Date: August 03, 2017
Name: D
Birth Date: August 04, 2017
How can I achieve expected output?
Use MMMM instead of MM
<ion-list>
<ion-item *ngFor="let user of users">
<div>Name: {{user.name}}</div>
<div>Birth Date: {{user.birthDate | date: "MMMM dd, yyyy"}}</div>
</ion-item>
</ion-list>
Suppose I have following three records in my model :
#<Rda:0xf6e8a0c
id: 1,
age_group: "18-100",
weight: "60",
nutrient: "energy(kcal/day)",
value: "2730",
created_at: Sat, 15 Oct 2016 08:21:43 UTC +00:00,
updated_at: Sat, 15 Oct 2016 08:21:43 UTC +00:00>
#<Rda:0xf6e8a0c
id: 2,
age_group: "10-15",
weight: "60",
nutrient: "energy(kcal/day)",
value: "2730",
created_at: Sat, 15 Oct 2016 08:21:43 UTC +00:00,
updated_at: Sat, 15 Oct 2016 08:21:43 UTC +00:00>
#<Rda:0xf6e8a0c
id: 3,
age_group: "20-100",
weight: "60",
nutrient: "energy(kcal/day)",
value: "2730",
created_at: Sat, 15 Oct 2016 08:21:43 UTC +00:00,
updated_at: Sat, 15 Oct 2016 08:21:43 UTC +00:00>
Now, I want to get all those records in which my given value falls in a 'age_group' columns ranges. For example: suppose my age is 25 then I should get records with ids 1 & 3 from the above records because '25' falls in between '18-100' and '20-100'
You might do
def self.foo(age)
all.select { |rda| Range.new(*rda.age_group.split('-').map(&:to_i)).cover? age }
end
I want to be able to delay the activation of the login. For example i can create an user monday, but i just want allow him to connect only from friday to logon on my network.
So i created an attribute on the file dictionary.conf
ATTRIBUTE Acc-start-date 3003 date
This attribute is used in the databse sql like an attribute
And in the /site-available/default in the authorise section
if (Acc-Start-Date < "%{Current-Time}") {
reject
}
But I get an error,
rad_recv: Access-Request packet from host 127.0.0.1 port 58341, id=131, length=277
ChilliSpot-Version = "1.3.0"
User-Name = "date"
User-Password = "date"
Service-Type = Login-User
Acct-Session-Id = "556ea52d00000004"
Framed-IP-Address = 10.10.4.200
NAS-Port-Type = Wireless-802.11
NAS-Port = 4
NAS-Port-Id = "00000004"
Calling-Station-Id = "00-1B-77-16-34-1A"
Called-Station-Id = "00-50-56-B2-BF-8D"
NAS-IP-Address = 10.10.4.254
NAS-Identifier = "vlan4"
WISPr-Location-ID = "isocc=,cc=,ac=,network=Coova,Vlan4_ssid"
WISPr-Location-Name = "Vlan_4"
WISPr-Logoff-URL = "http://10.10.4.254:3990/logoff"
Message-Authenticator = 0x96a538a9ed829e695c3d62f22e5d1962
Wed Jun 3 08:57:48 2015 : Info: # Executing section authorize from file /etc/freeradius/sites-enabled/default
Wed Jun 3 08:57:48 2015 : Info: +- entering group authorize {...}
Wed Jun 3 08:57:48 2015 : Info: ++? if (!NAS-IP-Address)
Wed Jun 3 08:57:48 2015 : Info: ? Evaluating !(NAS-IP-Address) -> FALSE
Wed Jun 3 08:57:48 2015 : Info: ++? if (!NAS-IP-Address) -> FALSE
Wed Jun 3 08:57:48 2015 : Info: ++[preprocess] returns ok
Wed Jun 3 08:57:48 2015 : Info: ++[chap] returns noop
Wed Jun 3 08:57:48 2015 : Info: ++[mschap] returns noop
Wed Jun 3 08:57:48 2015 : Info: ++[digest] returns noop
Wed Jun 3 08:57:48 2015 : Info: [suffix] No '#' in User-Name = "date", looking up realm NULL
Wed Jun 3 08:57:48 2015 : Info: [suffix] No such realm "NULL"
Wed Jun 3 08:57:48 2015 : Info: ++[suffix] returns noop
Wed Jun 3 08:57:48 2015 : Info: [eap] No EAP-Message, not doing EAP
Wed Jun 3 08:57:48 2015 : Info: ++[eap] returns noop
Wed Jun 3 08:57:48 2015 : Info: [sql] expand: %{User-Name} -> date
Wed Jun 3 08:57:48 2015 : Info: [sql] sql_set_user escaped user --> 'date'
Wed Jun 3 08:57:48 2015 : Debug: rlm_sql (sql): Reserving sql socket id: 3
Wed Jun 3 08:57:48 2015 : Info: [sql] expand: SELECT id, username, attribute, value, op FROM radcheck WHERE username = '%{SQL-User-Name}' ORDER BY id -> SELECT id, username, attribute, value, op FROM radcheck WHERE username = 'date' ORDER BY id
Wed Jun 3 08:57:48 2015 : Info: [sql] User found in radcheck table
Wed Jun 3 08:57:48 2015 : Info: [sql] expand: SELECT id, username, attribute, value, op FROM radreply WHERE username = '%{SQL-User-Name}' ORDER BY id -> SELECT id, username, attribute, value, op FROM radreply WHERE username = 'date' ORDER BY id
Wed Jun 3 08:57:48 2015 : Info: [sql] expand: SELECT groupname FROM usergroup WHERE username = '%{SQL-User-Name}' ORDER BY priority -> SELECT groupname FROM usergroup WHERE username = 'date' ORDER BY priority
Wed Jun 3 08:57:48 2015 : Info: [sql] expand: SELECT id, groupname, attribute, Value, op FROM radgroupcheck WHERE groupname = '%{Sql-Group}' ORDER BY id -> SELECT id, groupname, attribute, Value, op FROM radgroupcheck WHERE groupname = 'date_check' ORDER BY id
Wed Jun 3 08:57:48 2015 : Info: [sql] User found in group date_check
Wed Jun 3 08:57:48 2015 : Info: [sql] expand: SELECT id, groupname, attribute, value, op FROM radgroupreply WHERE groupname = '%{Sql-Group}' ORDER BY id -> SELECT id, groupname, attribute, value, op FROM radgroupreply WHERE groupname = 'date_check' ORDER BY id
Wed Jun 3 08:57:48 2015 : Debug: rlm_sql (sql): Released sql socket id: 3
Wed Jun 3 08:57:48 2015 : Info: ++[sql] returns ok
Wed Jun 3 08:57:48 2015 : Debug: rlm_sqlcounter: Entering module authorize code
Wed Jun 3 08:57:48 2015 : Debug: rlm_sqlcounter: Could not find Check item value pair
Wed Jun 3 08:57:48 2015 : Info: ++[chillispot_max_bytes] returns noop
Wed Jun 3 08:57:48 2015 : Debug: rlm_sqlcounter: Entering module authorize code
Wed Jun 3 08:57:48 2015 : Debug: rlm_sqlcounter: Could not find Check item value pair
Wed Jun 3 08:57:48 2015 : Info: ++[noresetcounter] returns noop
Wed Jun 3 08:57:48 2015 : Debug: rlm_sqlcounter: Entering module authorize code
Wed Jun 3 08:57:48 2015 : Debug: rlm_sqlcounter: Could not find Check item value pair
Wed Jun 3 08:57:48 2015 : Info: ++[dailycounter] returns noop
Wed Jun 3 08:57:48 2015 : Info: ++? if (Acc-Start-Date < "%{Current-Time}")
Wed Jun 3 08:57:48 2015 : Info: expand: %{Current-Time} ->
Wed Jun 3 08:57:48 2015 : Info: (Attribute Acc-Start-Date was not found)
Wed Jun 3 08:57:48 2015 : Info: ? Evaluating (Acc-Start-Date < "%{Current-Time}") -> FALSE
Wed Jun 3 08:57:48 2015 : Info: ++? if (Acc-Start-Date < "%{Current-Time}") -> FALSE
Wed Jun 3 08:57:48 2015 : Info: ++[expiration] returns noop
Wed Jun 3 08:57:48 2015 : Info: ++[logintime] returns noop
Wed Jun 3 08:57:48 2015 : Info: ++[pap] returns updated
My freeradius can't find my attribut, should I write somewhere the query sql to find this attribute ?
You might want to add this in your policy.conf and not default
if (Acc-start-date < "%{Current-Time}") {
reject
}