Drop Down Date Delivery - asp.net

I want to use a asp.net drop down to present the user a delivery date on checkout. What I'm not sure about is how to get the specific dates. What the user should see and be able to select in the drop down is the next Monday and Tuesday for the next two weeks. Any help would be appreciated.
thanks.

The simplest solution is to use the DateTime.DayOfWeek property (http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek.aspx).
You start with getting today's date, or, if today is Monday and you can't deliver for two days, so the next delivery will be a week Monday, then start with tomorrow. I am not certain how you would handle if I order tomorrow could I get a delivery date for the next day, so I would need that clarified.
Get the day of the week, starting with either today or tomorrow, extracting it from a specific date as explained here:
http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek.aspx
If it isn't Monday or Tues then just determine how many days you need to reach Monday or Tuesday, then add that number of days and get that date, and then just add seven and get the date.
I would prefer to let .NET determine the date of seven days from now, as you may change month or years.
That is the basic approach. If you get stuck when trying to implement it, I would suggest some code so we can help you determine where you got stuck.
There are other approaches, but this is probably the simplest to understand and implement.

Here's a pretty simple suggestion using a lot of LINQ:
private void LoadDeliveryDays(int period)
{
DateTime[] days = Enumerable.Range(1, period).Select(i => DateTime.Today.AddDays(i)).ToArray();
DropDownList1.DataSource = (from d in days where d.DayOfWeek == DayOfWeek.Monday | d.DayOfWeek == DayOfWeek.Tuesday select d.ToString("dddd dd-MM-yyyy")).ToArray();
DropDownList1.DataBind();
}
You probably want to change the d.ToString("dddd dd-MM-yyyy") and/or what value is actually used in the dropdown.

Related

fullcalendar wrong timespamp for midnight

I am using fullcalendar.io and I realized that if I create a new event in the month view, dragging across one or more days, it returns a timestamp for the end date which is later rendered as 12 am of the day after while it should be logic that a function date("what-ever-format", timestamp) returns 12 pm of the current day, or, in any case, not the following day.
Any idea how to fix this???

Access 2010 No records returned based on date/time field

I must be brain dead today because I cannot get any records to return in a SELECY query. I'm trying to select records for the last 30 days (since 2/8/2016). I know there are records in the database since 2/8/16. This is my selection criteria: >#2/7/2016 11:59:59 PM#. I'm not sure why I'm not getting any records. I've looked at the table and the field I'm trying to select on is Date/Time (General Date format). Any suggestions would be appreciated as this is making me crazy. Thanks for the help.
I would just use the date part of it, without the time. So...
=#2/8/2016#
If this is to be variable date for the last 30 days from today, you could also write it as
=Now()-30
Hope this helps.
Josetta
Use this criteria for your date field:
>=DateAdd("d",-30,Date())
or for a specific date:
>=DateAdd("d",-30,DateSerial(2016,3,1))
or, if 30 days means a month:
>=DateAdd("m",-1,Date())

How to know that it is a new month?

I want to know when is the New Month. So that I can do some operation
like, copy last month data [eg. Category.Title] from last month [Jan] to the new month [Feb].
Month Catagory
===== ========
Jan => Category.Title
Feb => New Category.Tile (copy based on Jan's data)
How do I construct the logic to detect that Today is a new month (so that I can preform the copy operation)?
Basically, I want to detect when is the New Month begin?
If all you need is the logic to check if today is the first day in a month, you can use the following code.
var d:Date = new Date();
if (d.date == 1) {
//today is the first day in a month
}
Depending on where/when you're doing this however, it may not have the effect you desire. Without more information, I can't really help you there.
You should employ this fabulous logic found on the provided link and go from there. Pretty much you need to find out if current date of the month. Lets say if today is the 15th of April, you will then need to find out how many days are there in April, 2012, and where does the 15th of April fall. And then have a counter count the remaining days until the new month (May) begins. You also want to make sure that you are checking for the leap year. This link also has a function that checks for the leap year. I am giving you a high level idea to go about getting what you trying to.
http://www.electrictoolbox.com/javascript-days-in-month/
Thanks a lot.

Showing only ONE week (Opening hours, each week the same)

I would like to know if it is possible to show only one week, to use this calendar for showing opening hours of a shop.
So :
- I don't want to show the day dates (only the day names) : OK
- I don't want to colorize the current day : OK
- I want the calendar display always the same week => I don't know how to do that...
Have you got any idea ? Is it possible to do that ?
Thanks a lot !
If you use the "goToDate" method:
gotoDate
Moves the calendar to an arbitrary
year/month/date.
.fullCalendar( 'gotoDate', year [,
month, [ date ]] )
IMPORTANT: month is 0-based, meaning
January=0, February=1, etc.
you could add your shop opening hours on the calendar for a given date, and then just show the date. However, you could also just add them for the current week being shown - this would then allow you to change times, for example, bank holidays etc. Have an array of special dates and print normally if not one of those dates...
Since version 1.3 and 1.4 fullcalendar is now able to show week view:
http://arshaw.com/fullcalendar/docs/views/
http://arshaw.com/fullcalendar/docs/views/Available_Views/
Example:
http://arshaw.com/fullcalendar/views/agendaWeek/

Setting report to current date

I have a report where it shows meetings and their requirements. However i just want the report to show ONLY today's stuff--not the entire week's worth.
I tried setting my group header (i'm grouping by day) to currentdate but yet it still shows me the entire week. I then have to go to the grouping tree and select today's date. Is there any way to run my report and have it ONLY show today's stuff and nothing else???
Any ideas?
Use the select expert to limit the results to today's date. printdate is a special Crystal Formula keyword.
{table.date_field} = printdate
Or, if you're working with a datetime db field you can strip the time with CDate
CDate({table.date_field}) = printdate
One way would be to change your query so that it's only getting one day's worth of data; that is, assuming your data contains a date field. To take it a step further, you could add date parameters to the query itself and leave the group headers as is. That way, you can have one day of data, or data from a specific date range.
If you have no influence (or desire) to change the way data comes into Crystal Reports, you could also add a formula via the Section Expert to suppress the group or detail section unless the date is the current date.

Resources