How to code two Sundays inside two weeks differently? - vb.net

I am saving days in my database but my problem is I shouldn't be able to save the same day.
It successfully saves because they both read "Sunday". How can I code such that the Sunday in the database saved last week is different from "Sunday" today, and so on?

Record meta-data for each save giving the date on which you are saving it, not the day of the week.
Then before you save a new day, verify that you have not yet saved a record for that date.

Related

How to freeze the historical data?

I have this assignment where i am having employee data. For example the excel screenshot.
I need to freeze the data every month. Which means that if the data changes in august then it should not affect the data which has already been uploaded in july. As you can seen the red marked cells should be eliminated for august but they will still exists for july month.
I am using redshift database for data and will be creating reports in tableau. There will be filter to select the month and data will be filtered according to month. My solution for this was to add a column named uploaded month so it will track the data on which month how many employees were active for a paritcular Job-ID.
Is there better way to do this? In this solution the history of data is kept, but not entirely from the beginning of time. I am looking for a solution in SQL, Tableau or in PySpark.

Group data by weeks since the start of event in sql

I’m a data analyst in the insurance industry and we currently have a program in SAS EG that tracks catastrophe development week by week since the start of the event for all of the catastrophic events that are reported.
(I.E week 1 is catastrophe start date + 7 days, week 2 would be end of week 1 + 7 days and so on) then all transaction amounts (dollars) for the specific catastrophes would be grouped into the respective weeks based on the date each transaction was made.
Problem that we’re faced with is we are moving away from SAS EG to GCP big query and the current process of calculating those weeks is a manually read in list which isn’t very efficient and not easily translated to BigQuery.
Curious if anybody has an idea that would allow me to calculate each week number in periods of 7 days since the start of an event in SQL or has an idea specific for BigQuery? There would be different start dates for each event.
It is complex, I know and I’m willing to give more explanation as needed. Open to any ideas for this as I haven’t been able to find anything.

SSRS Report subscription scheduling with flexible dates

I have a set of reports that are being updated 4 times a month on set dates; on 1,9,16 and 24th. When any of these dates occur on weekends the updating will be done the next monday.
Now I'm working on a schedule that will send emails to persons once the report has been updated, and the problem is those weekends.
Can I somehow script the schedule to skip dates on weekends and do it on the next monday instead?
You can do this using a data-driven subscription. You'll need to write a SQL query that checks the current day and determines if it's one of these cases or not. Have the query return the email addresses you want to send to if it's a valid day.
Then in the "To" field for the subscription you can reference the field from the query. Set it to run every day. The subscription will run that query every day and deliver the email only when the conditions are true.

How to Extend the End Date in a SQL Calendar Table?

I have a report that, according to users, started miscalculating dates in one field in November 2015. After some digging around, I found that one of the tables the field referenced seemed to have an end date on 2015-10-31.
The "D" field seems to represent the day of the week, with Sunday being day 1 and Saturday being 7.
Is there a way to extend the calendar so that it ends further into the future, for example 2049-12-31?
Our calendar table, for a variety of reasons, goes the the end of the current year. We have written a query that adds a new year to this table. This query takes care of most of the fields in that table. It does not touch the holiday field. That is updated manually through a web page.
We send ourselves reminders. Starting in March, we send monthly reminders that we should think about adding another year. After ensuring that the database segment has space, and that none of the definitions, such as fiscal periods, have changed, we run the query that adds a year.
Later in the year we start mailing ourselves reminders about the holidays. Then we check to see if HR has declared them, and if so, update the records accordingly.
This meets our business requirements. Yours will be different of course.

automatically renewing records when the last day of year

I'm developing a c# application that consists of Document Incoming System for my police station.
In this system, variable document's contents are been saved to an SQL database. I must give them a "Document Number".
I'm achieving all of these, but i want that every years last day such as 31.12.2014, the numbers that have been given to a document like "2145" will turn to "1" at the the first day of year 01.01.2015.
So, the records must be 2014/2145. and the last days of years turns to 2015/1.
How can I achieve this?
You count the existing documents for the same year, then add one.
So if you want to store a document that belongs to 2013, you first count how many existing documents you have in 2013, then add one.
I can't write the sql for you, because you haven't described the data structure, but it should be simple enough using SQL COUNT, and DATEPART to retrieve only the year from a date field.