Datetime FromDate To Date - winforms

I have a Window from that contains 2 date Pickers dtpFromDate and dtpToDate, I want to know how to validate that user selects From date the first date of selected month and To date is the last date of the same month.

From your description, having a months dropdown should be enough for your needs (though you may also require a years dropdown).
You can construct the first and last dates from that piece of information easily enough.
var fromDate = new DateTime(theYear, theMonth, 1);
var toDate = fromDate.AddMonths(1).AddDays(-1);

Related

How can I exclude previous months of the selected month in Looker Studio?

I am trying to create a month on month bar charts. When the user selects a month bar in another chart or when she tries to filter to one particular month, it should show bar of selected month as well as bars of subsequent months.
I thought that it would be good to generate a list of months from selected month to the end of year and have it as a dimension (x axis).
For instance, the selected month is November. So I should have a list of month from November to December.
To get the end of year:
month(datetime_add(BillingDate,interval 12-month(BillingDate) month)) -- value is December
However, I am stuck on how to to generate the list of month.
Create a date column in your dataset, ideally at a day level or if the data is already aggregated, set to the first of the month. Then create a date dimension_group in Looker with month as a timeframe and datatype of date.
dimension_group: BillingDateDate {
type: time
timeframes: [
date,
week,
month,
year
]
convert_tz: no
datatype: date
sql: ${TABLE}.BillingDate ;;
}
then in your Looker dashboard, create a filter and use the BillingMonth field (generated from your dimension group) to filter the month on or after the required month

Extjs 4.2 datefield show only year and month no date

I need to override the datefield dropdown to show only the year, month but no date.
And on selection the field should set the date in format YYYY-MM since i just want to set the year and month values in date field like 2018-03 or 2018-04
here is the senchaFiddle
I just want the second image like dropdown(just showing the year and month) to show on the datefield dropdown without showing the dates
Month Year date field is shown as from #Alexander's answer in this fiddle.
Another option is using stock date picker with the monthPickerPlugin
ok ive just tried this and it worked greatly also for extjs4
here is the fiddle

Alexa slot AMAZON.DATE handle dates without years

I am building an Alexa skill and using AMAZON.DATE slot type to get a date.
My problem is that when a user says a date without a year, Alexa processes it and returns the date string with a future date.
Example - Today is 2017-09-20, User asks Alexa about date 'Sixth June', Alexa returns 2018-06-06.
I want to use the closest past date instead of closest future dates, for the case when the user doesn't specify a year in the utterance. If the user specifies a year, I don't want to change the date year.
I can't handle this on AWS Lambda using Python, as Alexa sends the complete date string, no matter if the user provides the year or not, in the JSON body.
I don't know if it is even possible to handle such user inputs with Alexa. Is there something I can do about the AMAZON.DATE slot or some other way to handle such user utterances?
You cannot do that with built-in date slot,
Utterances that map to a specific date (such as “today”, or “november twenty-fifth”) convert to a complete date: 2015-11-25. Note that this defaults to dates on or after the current date.
Source :- https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#date
one logic you can try it out is to do a custom logic. Take the difference between todays date and next year same date of user input. If the difference of months between those is greater than 6 months then the nearest would be future date. If difference is less that 6 months then past date. Say user gives an input July 25th (on 2017 ) and todays date is August 25th 2017. Now you can add 1 year to July 25th then you will get July 25th 2018. Difference between July 25th 2018 and August 25th 2017 is greater than 6 months so the date you want is past date, which is July 25th 2017 and vice versa. For more accuracy you can count in days instead of months
After converting Alexa's slot input date string to a js date object, (probably with amazon-date-parser) the below could work
if (dateobj > new Date()) {
var currentMonth = new Date().getMonth()
var dateMonth = dateobj.getMonth()
var offset = dateMonth > currentMonth ? 1 : 0 // if current month is to be set with past year use >=
dateobj.setFullYear(new Date().getFullYear() - offset);
}

How can i set views filter to show specific content based on actual month?

The content that i want to show is random pictures in views block. Few of them needs to by shown on January, others on February, others on March, and so on.
Showing of specific content will reapeats every year (example: only in january in every year)
I have created vocabulary for that content type with "January", "February", "March" as values. Every photo has one of these values.
And now is the part where i am stuck:
I want to add views filter which points to that vocabulary with additional actual date rule, like:
IF date('m') = january THEN set filter to Vocabulary Months = January else
IF date('m) = february THEN set filter to Vocabulary Months = February ... and so on.
Can someone tell me by wich modules i will achieve this?
I did this already by using Date Repeat module but for user it means, that he needs to put some extra values in 3-4 additional fields - and that is "not simple".
Any advice?
I'd switch from a taxonomy field to a date field (i.e. set month as a date field value on the images), then use the current relative date as a filter.

How to compare two dates in Cakephp based on day, month, and year

I have a (hopefully) quick question. I have two dates stored in a database, ['Event]['start_time'] and ['Event']['end_time']. I want to compare the dates to see if they match based on day, month, and year, disregarding the hours, minutes, and seconds they were created. How do I pick out the details of my dates when they're in this format?
Are you trying to pull results where the start and end time match? You can do it like this:
$results = $this->Event->find('all',array('conditions' => 'DATE(Event.start_time) = DATE(Event.end_time)'));
DATE() is a MYSQL function that will just return the date in YYYY-MM-DD format and drop the time portion.
If you already have the data selected and want to compare it later, you can use the php functions date() and strtotime() like this:
if(date('Y-m-d',strtotime($start_date)) == date('Y-m-d',strtotime($end_date))) {
//dates are equal
}
where $start_date is ['Event']['start_time'] and $end_date is ['Event']['end_time']

Resources