which dates given week number, bash - bash

In Bourne shell, I need to know which dates belong to the same week. For example, week 16 in 2013 starts on April 22nd and ends on April 28th. Using the "date" command I can get the week number for a certain date but I need to go the other way around.
Thanks

A cheap way to obtain week numbers - Use ncal, the week numbers are output below calendar
e.g.
ncal -w 4 2013
or
ncal -w 2013

Related

Displaying date - three days in long format minus the year in Freemarker

looking for way to display the date in freemarker as "June 1", so long format minus the year. I also need to output the date minus 3 days. So the code that works is
${(.now?long - 259200000)?number_to_date }
but that displays the year as well (June 7, 2021)
I need to get rid of the year.
I figured it out. For anyone who is reading this in the future:
${(.now?long - 259200000)?number_to_date?string['MMMM dd']}
prints as
Current date, minus 3 days, without year. So for me rn :
June 7

Complex Date Range

I'm working on the following query and cant figure out the final piece of it. I need my query to give me a result set between the previous business and the previous business day minus (-) 28 days. (e.g. date range between 10/28/2015 and 10/28/2015 -28) The query that I wrote so far is only giving me the -28th day (09/30/2015) and NOT a range in between the previous business day and the previous business day -28. My research shows a couple of different ways of doing it and so far none have worked for me.
SELECT SMBL, SUM(NET_FLOWS/1000000.00)
FROM HISTORY
WHERE DATE - 28 = DATE AND DATE = TO_DATE('10282015','MMDDYYYY')
AND SYMBOL IN ('AAA','BBB')
GROUP BY SMBL
First off, date ranges are easy using BETWEEN, so you do the quick solution:
WHERE DATE BETWEEN (SYSDATE-28) and (SYSDATE-1)
Then you realize your dates have time components, so to include all of yesterday and all of day-28 you need to:
WHERE DATE >= TRUNC(SYSDATE)-28
AND DATE < TRUNC(SYSDATE)
Then I look at your rule "previous BUSINESS day" and ask - what are your business days? On a Monday to go up to the previous Friday? Or Saturday? Or are you a 7-day-a-week business? How about statutory holidays? And is it 28 CALENDAR days back? Or 28 BUSINESS days?
Ahh business rules. The devil is always in those details....

How did windows/c# remember the current systems year/date

Recently i was working with unit testing for my project.
I've given a task to test the method. The method should return the recent quarter date as per the current system date.
So, I've called the current system date using the following c# code:
string currentYear = DateTime.Now.ToString();
When i run the query it worked as expected.
So, its time for my tactics to raise a bug for that method. Hence I've changed the system date to 10/01/14 (dd/mm/yy).
Also I've customized current system date format to only keep last two digits of the year.
Ex: if year is 2014 the it shows only 14.
You can observe the short date and the long date in the following image.
When i run/debug the test in Visual Studio 2012, it still displays as 2014 as the current system date though I've modified it to 14.
Question: The real question is how did the system/program took the current year as 2014 even the system date is changed to 14. It may be silly but my doubt is Why it is not 1914 or 1814 and why it is 2014 ?.
Where did it store the current date or year information ? Does windows manage this stuff or did the C# taken care of the date ?
The real question is how did the system/program took the current year as 2014 even the system date is changed to 14. It may be silly but my doubt is Why it is not 1904 or 1804 and why it is 2014 ?.
C# only retrieved the date from the system, it was Windows that determined what data to send.
In the case of two-digit dates, Windows allows you to define what they mean in the Regional and Language applet in the Control Panel. This way you can specify the range you want it to represent depending on your usage.
The display of a date is not how it is stored, just how it is displayed.
January, 1st, 2014 may have a multitude of different formats, e.g.
2014-01-01
01-01-2014
01-01-14
1/1/14
Jan/1/14
001-2014
But all are held internally exactly the same way.
Note the advanced settings on your screenshot - this will indicate to many windows programs how to interpret a year entered as 2 digits, so it knows if it should regard a date entered as XX as 19XX or 20XX - this will cover manually entered dates, not the system date
Your C# application didn't store that date, Windows handled it for you.
As Sean mentioned, by changing from YYYY to YY you only changed how the date is displayed, not how it is stored. Windows doesn't store its system time information into a specific date format. Instead, it records the number of 100-milisecond intervals since 00:00 January 1st, 1601. That way it keeps the tracking of time independent of how it's displayed and allows you to display the date and time in a number of different formats.
As a curiosity, that specific date was chosen because the Gregorian calendar operates on a 400-year cycle (when it starts to repeat itself) and 1601 was the first year of the cycle that was active when Windows NT was being developed.
On a side note, Unix systems store that information as Unix Time or POSIX Time, counting the number of seconds elapsed since 00:00 January 1st 1970.

Excel VBA - Year to Date validation

I have a variable input in my Userform for the start of the Financial Year. I want to be able to validate the entry, so that it will prompt the user if the date entered is not the a start date for a financial year.
Eg.The start of my Financial year is 01 Jul 2012, so if I was running a report for the month's Jul 2012-Jun 2013 the Financial is entered will not come back with an error message. But if the monthly report I'm running is "Jul 2013", or "Aug 2013", and my YTD entered is "Jul 2012", I want an alert to say "Do you want to reset your YTD entered?"
Thanks.
There is a lot you aren't explaining... your first example is a 12-month report, then later you mention monthly reports. Using your example, if the monthly report is running starts Aug 2013. Is the user input that raises the prompt ALWAYS wrong, or only sometimes?
Regardless, things like the first day of the year don't change. Why not simply hardcode the first day of the last & next 20 (?) fiscal years, and verify the user's input matches one of them. I would actually suggest in-cell Data Validation (validating against a List comprised of the first days) but you stated you were using a UserForm.

How to write a shellscript date check that will not To run Except 3rd week sat, Sunday and 4th week Monday of the month

E.g. the schellscript will not run on april 18, 19 and 20 and then for may is 16, 17 and 18 and so on
You can get the weekday in numerical form from the date command using date "+%w".
The output will be 0 for Sunday, 1 for Monday etc.
You can get the day of the month using date "+%d". Subtract one from that and divide by 7; that will give you how many complete weeks there have been in the current month.
From there, it's just a simple bunch of if/then statements. If you need more help actually implementing this, just ask.
Hope that helps!
I would advise to use cron for this kind of things, to separate the planned execution from what the script really does.
Have a look here on how to use cron.

Resources