Dateadd() like alternative in Visual Fox pro - visual-foxpro

How can I add year to Date.
I want to add 65 year to date (12\11\1952).
I have tried "12\11\1952" + 65 ,but it is not giving the required value i.e.
12\11\2017.
please suggest how can i achieve this.

When you add an integer to a Date, you are adding days. ie: Date(1952,11,12)+65 adds 65 days to Nov 12th, 1952.
If you add an integer to a DateTime then you are adding seconds. ie: datetime() + 60*60 adds an hour (60 seconds * 60 mins) to now.
To add a year to a date in VFP, you use GoMonth(). To Add 65 years you use 65 * 12 months:
yearsAdded = GoMonth( Date(1952, 11, 12), 12 * 65 )

Related

DAX number of days

Can you please help how I can return the total number of days for each month in a given quarter?
For example, I already have 92 days for December 2025 but how can I show 92 days for October and November as well?
If you want only a count, you can use measure:
QuarterDays = calculate(countrows(VALUES('Calendar'[Date])), FILTER(ALL('Calendar'), selectedvalue('Calendar'[Year]) = 'Calendar'[Year] && selectedvalue('Calendar'[Quarter]) = 'Calendar'[Quarter] ))

Cron expression isn't working as intended for spring boot

I wan't to have a method run every sunday at 1:30 PM so far I can get thing to run like every 10 minutes or at 1:30 every day, but now specific day
Here is what I have so far
/**
* Fires at 1:30 PM sundauy
*/
#Scheduled(cron = "0 30 13 * 1 ?")
fun sendNotifications() {
}
I think the problem is in the day of month field possibly? or sunday isn't 1 indexed. I see in other con implementations its 0.
the 5th field is used for "month" while 6th field is for "day of week" (see here and here), so your expression ("0 30 13 * 1 ?") will fire your method at "13:30 of every day in January".
weekday names can be given as the first three letters of the English names. in order to schedule a method to run "every sunday at 13:30" this expression can be used:
#Scheduled(cron = "0 30 13 ? * SUN")

Count next X days without Sunday using Laravel carbon

I am developing a subscription based application using Laravel. I want to change the state of the user to expire after 75 days of subscribing to the package. I want to exclude Sundays from these 75 days.
Consider a scenario where user's account is verified today and he has only access to the premium functionalities for 75 days(without Sundays). After the 75 days, the user needs to resubscribe to get access to the premium functionalities of the application.
I will then set up a middleware which will check if the user's subscription is expired or not.
I have two scenarios to check for expiration:
Save the expiration date column in the users table.
Verify each user's request based on verified_at (datetime) column and prevent premium access if the user subscription is over more than 75 days without Sundays.
I want to achieve this using Laravel Carbon or any other alternative library/functionality.
After 75 Days from Today(11 June) is August 25 🙅‍♂️
After 75 Days from Today(11 June - Excluding Sundays) is September 07 👈
Reference: https://getcalc.com/75business-days-after-today.htm
If 75 is fixed, than you could easily calculate the number of Sundays in the period, and so then you just need adding those days to the 75:
$period_in_days = 75;
if($user->verified_at->dayOfWeek > 2)
$period_in_days += 11;
else
$period_in_days += 10;
The point is, in 75 days there could either 10 or 11 Sundays, and so in order to decide whether there are 10 or 11, we need to check which day is the first day.
Let's say is Monday the first day, so the 75 days should looks like this
1 - Monday
2 - Tuesday
...
71 - Monday
72 - Tuesday
73 - Wednesday
74 - Thursday
75 - Friday
Let's say is Tuesday the first day, so the 75 days should looks like this
1 - Tuesday
2 - Wednesday
...
71 - Tuesday
72 - Wednesday
73 - Thursday
74 - Friday
75 - Saturday
Let's say is Wednesday the first day, so the 75 days should looks like this
1 - Wednesday
2 - Thursday
...
71 - Wednesday
72 - Thursday
73 - Friday
74 - Saturday
75 - Sunday
So if the first day is not neither Monday and Tuesday, then there will be 11 Sundays (10 + the 1 that appears in the [71- 75]), otherwise there will be only 10 Sundays
I can count next 75 days excluding Sundays using the following PHP function
function Next75Days($StartingDate){
// Count Next 75 Days excluding Sundays
$Days = 75;
$d = new DateTime($StartingDate);
$t = $d->getTimestamp();
// Loop for 75 days
for($i=0; $i<$Days; $i++){
// Add 1 day to timestamp
$addDay = 86400;
// Get date of next day
$nextDay = date('w', ($t+$addDay));
// if it's Sunday, do $i--1
if($nextDay == 0) {
$i--;
}
// modify timestamp, add 1 day
$t = $t+$addDay;
}
$d->setTimestamp($t);
return $d->format('d M Y');
}

How to find number of days left from now to an epoch time in grafana elasticsearch

Example: I want to find number of days left from now (1576477782) to August 22, 2020 7:39:13 AM (1598062153) which is 249 days, 19 hours, 39 minutes and 31 seconds. How this can be done in grafana with Elasticsearch as datasource. I can get "1598062153" as a value of a metric in ES.
This can be resolved by doing 1576477782 - (new Date().getTime() / 1000)
The (new Date().getTime() / 1000)--- this will give current date in Epoch Seconds

Converting a difference of 2 24-hr times into time

Forgive me for my ignorance if its too easy and if its not the right place to post. I have 2 24 hours times strings as 1544 and 1458. Their difference should be 46 minutes but when I subtract them it yields 86 minutes as follows.
1544
-1458
-------
86
Can someone tell me how can I find a time difference of 2 24-hr times?
Hour doesn't have 100 minutes, but unfortunately only 60. You need to do this:
15*60+44
-14*60+58
---------
46
If you are working in C#, you can try to parse them to DateTime using
DateTime date1 = DateTime.ParseExact("1544","HHmm",CultureInfo.InvariantCulture);
DateTime date2 = DateTime.ParseExact("1458","HHmm",CultureInfo.InvariantCulture);
and then subtract them:
TimeSpan diff = date1 - date2

Resources