how to changes Start period date and End period date other date form? We want to show 09-2022 to September-2022.
How to solve is this date format?
Start period : 09-2022
End period : 09-2022
This format is false.
We want to
Start period : September-2022
End period : September-2022
How to fix it?
One of the ways to do that will be to add the MasterFinPeriod table to the report and add two relationships to the table which you are filtering by Fin Period. In my case I am filtering the INItemSiteHistByPeriod table, so the relationship is added to it. Then you need to change the formula for your Start and End Periods formulas to be as below and that will result in a report with the month being the text description of the period and the year. Of course, this works with the assumption that your Fin Period descriptions are the default ones which are the Month names.
=[StartPeriod.Descr]+'-'+[StartPeriod.FinYear]
=[EndPeriod.Descr]+'-'+[StartPeriod.FinYear]
Related
I have app where is datagridview with data from sql database - and a want to modify every row. I have button for this and if i will click there will appear new Form and there I can modify every record, but I want to that user can edit only records up to the previous day until 6 am , later records user cannot modify.
if (DateTime.Parse(labelDate.Text) < DateTime.Now.AddDays(-2))
{
labelNotice.Text = "Cannot modify records older than 2 days"
button1.Enabled = false;
}
My problem is that i dont know how to make date-time limit for this. I have labelDate where I have date of creation and I need to compare with actual date and time and I need to app will say to user that if labelDate is older than previous day until 6am you cannot modify nothing. Now I have only compare date of creation and if its 2 days older button1 will be disabled.
But I need date and time to compare.
How I will restrict a user to enter only max date of the previous entered date?
I want to enter only onward date and block backward date in SQL and c#.net in windowform?
In the blow image textbox "Auto Most Recent Date (Last Date)" is backward date and textbox "Enter Next Date" is onward date.
You clearly know how to query a database, so run a query like:
SELECT MAX(somedate) FROM courtcases WHERE casenumber = #whatever
And use the output of it on your date time picker
nextDateDateTimePicker.MinDate = <the DateTime you queried>
If the min date is a day later, use AddDays(1) on the date you queried
(Not that that looks like a standard win forms datetimepicker but I’m sure whatever you’re using will have a similar facility)
I don’t think you need to go to the extent of protecting your insert sql against hacking to ensure the user hasn’t modified the ui in some way and put an illegal date in
I am writing a utility to configure when certain reports are going to be automatically generated.
The next piece will be some background task (probably a Windows Service) that will poll the database to know when to execute these recurring operations. I came up with this initial table design:
ReportScheduler
---------------
AutoID int
MemberID VarChar(6)
ReportID int
RunWhen DateTime
...but soon realized that "RunWhen" isn't going to cut the catsup, because there are going to be multiple times a given report needs to be run for a given Member (once it runs, the value is no longer valid/useful).
Before showing the next candidate table design, though, a word about when these reports can be done (generated and emailed): the configurer can set them up to be run on a particular day of each month (the 1st, the 10th, the 17th, whatever) OR according to a pattern, i.e. they can be set to something like "the first Tuesday of each month" or "the last Friday of each month" or "the first Monday of each week" (IOW, every Monday). So I came up with this:
ReportScheduler
---------------
AutoID int
MemberID VarChar(6)
ReportID int
DayOfMonth int
PatternOrdinal VarChar(6) // First, Second, Third, Fourth, or Last
PatternDOW VarChar(9) // Monday, ... Sunday
PatternInterval VarChar(5) // Week, Month
...but then realized that that doesn't make too much sense, either, because code would have to run to calculate whether any date that equates to the DayOfMonth or Pattern combination of fields has been reached or surpassed every time the db is polled. And then what would prevent that from triggering forever after that, too?
SO, I think I need to combine these ideas, but instead of RunWhen, call the DateTime field NextExecution, and update it each time the report is generated for a given Member:
ReportScheduler
---------------
AutoID int
MemberID VarChar(6)
ReportID int
NextExecution DateTime
DayOfMonth int
PatternOrdinal VarChar(6) // First, Second, Third, Fourth, or Last
PatternDOW VarChar(9) // Monday, ... Sunday
PatternInterval VarChar(5) // Week, Month
When the NextExecution time is reached or surpassed, the Service generates/emails the report. It then calculates when the next execution should take place (based on the DayOfMonth or Pattern* fields) and updates the NextExecution field with that value.
This seems logical to me, but I'm sure this is a challenge that has been met before, and wonder if there is a standard way of accomplishing this that may be cleaner than what I've proposed.
Assuming that you're keeping a log of when these reports have been run, you could use that with your second method to prevent a report from running multiple times. You might want to incorporate some sort of rule that you will only try to run reports that have passed their due date within "X" days also.
Another potential design would be to keep a table similar to your first method, but fill it in when a person creates a new schedule out through the next 10 years (or some other sufficiently large time span). Keep a table that lists out the schedules that have been created by users and link the scheduled dates back to those schedules so that you can delete them if the user cancels a schedule. You'll need to decide what you want to do about schedules that overlap (both schedules happen to land on the same day this month and call for the same report to be run for example). Do you run the report once or twice? How you handle that determines how you might have to code around maintaining the calendar when a user creates/deletes schedules.
I end up custom building a lot of web based reports for clients of the software we produce, and I'm relatively new to development, so I encountered an interesting issue that I wasn't sure how to handle. I've worked out the specifics, but I'm sure there are better ways of handling this, and also if anyone encounters this I wanted to be able to share the result of my work this morning. I'm eager to be a productive member of the community, but am also open to any feedback regarding my question/answer/approach etc.
The report is generated and the user is allowed to give a start and an end date, but throughout the generation of the report the date ranges can mean multiple things. In one sector of the report that date range inputted pulls months in the range, which was easy enough to pull from the DateTime string broken up into manageable chunks. In other areas the range is treated as such, and the data pulled is aggregated over the range. The challenge I encountered was a sector of the report where data is aggregated based on the week so that the presentation of the report shows each week (1/1/1901 - 1/7/1901) and the columns of pertinent data follow for all the weeks affected in a chosen date range.
What I did to alleviate the issue was to take the given date, and from that work out the date of the 'first' day of the week using the built in DateTimeFormat.FirstDayOfWeek, then establish the date of the end of that week adding six days to the date, committing the dates as start and end to a datatable, and then adding one to push the date into the following week.
Also, to ensure the set has an ending, I compare the inputted end date with the calculated end date of that week, and eventually the subtraction of those dates will end in a negative number or zero which denotes the inputted end date falls in the week just committed to DataTable. I'm sure there's a better way to do this, but it works nonetheless. I hope this saves at least one person the 20 minutes it takes. Thanks!
String sBeginDate = "";//Given in input
String sEndDate = "";//Given in input
DateTime weekStartDate;
DateTime weekEndDate;
DataTable dtWeeksInRange = new DataTable();
DataColumn dcWeekStart = new DataColumn("WeekStart");
DataColumn dcWeekEnd = new DataColumn("WeekEnd");
dtWeeksInRange.Columns.Add(dcWeekStart);
dtWeeksInRange.Columns.Add(dcWeekEnd);
DayOfWeek firstday = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
weekStartDate = Convert.ToDateTime(sBeginDate) ;
do
{
while (weekStartDate.DayOfWeek != firstday)
{
weekStartDate = weekStartDate.AddDays(-1);
}
weekEndDate = weekStartDate.AddDays(6);
dtWeeksInRange.Rows.Add(weekStartDate, weekEndDate);
weekStartDate = weekEndDate.AddDays(1);
}
while ((Convert.ToDateTime(sEndDate).Subtract(weekEndDate)).Days > 0);
foreach (DataRow dr in dtWeeksInRange.Rows)
{
//Outputting the set of dates to the page
Response.Write(Convert.ToDateTime(dr["WeekStart"]).ToShortDateString() +
" - " +
Convert.ToDateTime(dr["WeekEnd"]).ToShortDateString() +
"<br />");
}
I have a date of birth field in the database which is of datatype date. I have three dropdowns for the same in my aspx page. One dropdown for day,one for month and one for year. If the user selects only day and month or month and year or any combination. How to insert that into the date field into the database.
If the user selects only the day and month or the month and the year or any combination as such. How to insert this into the database?
Thanks,
Two options:
Keep day, month and year in separate (nullable) fields in your database
Keep a DateTime field in the database, populate it with "dummy" data when it's not provided, and have a separate field to indicate what information was provided
The first sounds more sensible to me - it's not like you can really do many sensible date-related queries with "19th of some month in 1976", and it means your data accurately represents what the user specified.
Don't allow user to submit answer until he selects all the field. That's the standard way. you can use validator for it.
Or else try this(i am not sure about this)
1. Keep date field null.
And/Or
2.If (txtDate.Text = "") Then
cmd.Parameters("#Date").Value = sqldatenull
0000 isn't a valid year; firstly I'd revisit the requirements for the input form to decide what is optional and possible add validation.
If it is only the year that is optional then you could simply store 0001 as the year.
dt = new DateTime(Math.Max(1,dob_year), dob_month, dob_day);
If day and/or month are optional then a DateTime isn't the right data type because you cannot store null values so having separate fields for day, month, year is the only option.
A Date will always need all a day, month and a year because it refers to an actual day in the past, present or future.
All dates have to be in the range 01/01/0001 to 31/12/9999, so there is no way of storing the year 0000.
For your problem there are two options:
Store the day the, the month and the year in three separate fields.
Store the date in the usual way, setting the unspecified parts of the date to some default values. Then use a second field with a tinyint to store three bit flags which tell you which parts of the date are valid and which aren't