Krajee date range picker, doesn't work with today date - twitter-bootstrap-3

Enter in http://demos.krajee.com/date-range and search for: Single date and time picker without range. Then, clear the default date and try to select today date. Nothing appears. It looks that dont work when select "today" date if there is no previous value in the field.
Is not that a bug? I've googled, but nothing appears about this issue.
So, how can I select the "today" date if previously there is no value in the input field?

I guess this is by desing - if the date is the same as previously selected nothing is changed. And because removing the field text does not trigger the underlying js value widget still thinks the date is there.
You can verify it by changing the date by hand and then clicking the calendar icon - marked date is not changed to the new one.
So answering your question:
If previously there was no value you can select today's date without a problem, only if the today's value was there and it was deleted by hand selecting today does not make it reappear.

Related

Why does the date disappear in SSRS report filter?

I'm working on a report in SSRS (Report Builder).
I created 2 parameters: 'date_from' and 'date_to' (and also added parameters to my query which I assigned to report parameters). Need to say that I used 'Convert' on a date becuase it was dat+time format in my dataset - that's why I converted it to date format.
Default value for 'date_from' is =DateAdd("d",-1,Today()), default for 'date_to' is just =Today()
When I run report everything is ok - proper data is returned based on dates but the problem occurs when I try to change dates in the filter above the report.
First of all - date doesn't show up in filter field when I choose it from the calendar, I can see just empty field as below (after setting default values for dates). Don't know, maybe this is how SSRS works:
Second - when I choose date from filter the date doesn't show up in date field (e.g. "Start date') but disappears. So I can't choose dates at all. Sometimes I can choose a date for 'Start date' but when I choose date for next field - 'End date' then date from 'Start date' disappears. And finally the result is as in the picture I pasted above - empty date fields.
So, summing up - I can set default values but when the report runs and I need to change dates it doesn't work at all.
Is it some kind of a bug? Or maybe I need to set other options or date formats?

Microsoft Access date comparison in query not working

I added the following field in a query:
IIf(Date()<[NextQDue],"Less","Greater")
The field NextQDue was created in a different query and formatted as Short Date. The value in NextQDue is 12/20/2018. Today's date is 1/1/2019. The query spits out "Less" when it should spit out "Greater." If I change the statement to Date()>[NextQDue] it spits out "Greater" when it should say "Less." I cannot figure this out. I believe I've formatted dates correctly, but nothing is working.
Always handle dates as Date, not text, not numbers, no exceptions.
So, adjust your query and change NextQDue to return a true date value.
If you need to display the value of NextQDue somewhere else, apply the format to the control displaying it.

vb.net datetimepicker default date

I am having an issue with a datetimepicker field and am wondering if what I want to accomplish can be done or not. I have a datetime field in my 'Customer' table called 'LastVisit'. When the Customer is created, the LastVisit field is empty or null.
When the user enters the edit screen for a customer, if they don't change the LastVisit field and then save the record, it stays empty - - which is what I want it to do. Here is the problem though, if I set the datetimepicker.value in the screen design it stays that date, so eventually the users will need to click forward many months to get to the current month. If I set the datetimepicker.value = today in the Form_load event, then it sets the value and it gets written to the Customer record even if the user does not go into that field.
What I would like to do is have the default date be 'today', but still have it so the LastVisit field will remain empty unless the user sets it. Any ideas on how to accomplish this?
I figured it out. I had set a date as the value in the Properties of the datetimepicker field when I first created the form. I was looking for other ideas and found that I could right click on the 'value' property and reset it to the default, which is the current time. Now it behaves like I want.

sql passing a date to a datetime

I have a few user controls I made in wpf that are driven by two datepickers. One picker controls the begin of the date range and the other one controls the end of the date range.
I had issues with the datepicker.selecteddate property giving me the time along with the date and then my sql results were not all there because the passed in time value filtered out a lot of my results. I ended up finding that if I formatted that time to midnight then my results were all there, but every time I picked a new selection in the datepicker it would reset the formatted time.
After some testing I found that I can just pass the value of the datepicker text property as the parameter. This property's value is a string type and is set to the date value of the current selected date (ex: 3/14/2012 5:00:32 AM is selected date then '3/14/2012' is the text value).
So far, surprisingly, this seems to return all my results I wanted.
I was wondering about why this actually works (is it b/c the 'mdy' literal format is supported and the default?), and if there is any negative drawbacks to doing what i'm doing? I know a lot of times just because something works doesn't mean you should use it in production. I share the tables with others or I would just convert the datetime fields and parameters to date and be done.
I hope my question makes sense. Sometimes they don't. If there are questions leave comments and i'll chime in.
As far as negative drawbacks, I cannot see any - this is how we handle it throughout many apps/DBs. However, the way I typically handle it is if the record being added doesn't need the time (i.e. BusinessDate, LoadDate) then I add the record with the only the Date and no time - so the value is always in the format 3/14/2012 12:00:00 AM which I think makes querying significantly easier since you don't have to deal with the time
Then in my UI (winforms) when performing a search on the date with a datetimepicker I use the datetimepicker.Value.Date which gives the date in a similar format (3/14/2012 12:00:00 AM).
If you have a field in a table that needs a datetime, then use it and you can search the date by either formatting the date in the table or using date > yourdate AND date <= yourdate which would include the date you are searching.

Problem reading Excel cells containing datetime in VBA

Some background: For a project I'm working on (building an XML DOM from a given excel spreadsheet of customer data), I need to be able to read the contents of a cell with a datetime in it. The cell in question contains "7/22/2011 0:00," and when I right-click->format cells, it tells me the category is "Custom" (not in the standard date category), and of type "m/d/yyyy h:mm." Yet when I select the cell, the formula pane displays it as "7/22/2011 12:00:00AM." So all three of these attempts to categorize the datatypes don't match up.
The problem: When I display the cell contents using ActiveWorkbook.ActiveSheet.Cells(x,y) in a MsgBox for debugging purposes, it only shows 7/22/2011 (cutting off the time). It can't be the space in between the date and time that throws it off, as I am successfully reading cells with spaces in them elsewhere in the spreadsheet.
Can anyone tell me why this is happening, or point me in the right direction for a VBA/Excel method that doesn't do this weird cropping thing that Sheet.Cells(x,y) is doing? Thanks. If only I had a penny for every time datetime datatypes caused problems for me..
Internally, Excel stores dates as numbers. It doesn't implement a date type. The number is the number of days since some point in the past (1900 or 1904, depending on the operation system, with some mistakes built-in regarding leap years). Time is represented as the fractional part of the number.
To make it look like a date to the user, you have to assign the cell a date format. Then the number is displayed as a date in the cell. (Excel assigns a date format automatically if you enter somethings that looks like a date to Excel.)
When you use ActiveWorkbook.ActiveSheet.Cells(x,y), you create a Range object and call its default property, which is Value. Value has a lot of magic built-in. In your case, it looks at the cell format and - seeing a date format - in converts the internally stored number into a Variant of subtype date. When you display it using a message box, the next trick happens. If the time is 0:00, the date is converted to a string without time. If the time were different from 0:00, it would be converted to a string with date and time. The date format is taken from your user's settings. Its independent of the date format you have assigned to the Excel cell.
If you use Value2 instead of Value (e.g. by using a messag box to display ActiveWorkbook.ActiveSheet.Cells(x,y).Value2), then you'll see the internal representation of the date, namely a number.
When you edit a cell, Excel uses yet another date format so you can see and edit all parts of the date: year, month, day and possibly hour, minutes and seconds. This is because your cell's date format could be restricted to just the month name.
Another complexity is added by internationalization. Certain date formats aren't applied directly but are a hint for using a date format from the current user's settings. So the format is first replaced with another date format and then applied. Furthermore, certain parts of the date and time formats are affected by the user's settings. And finally, the patterns of the date format are translated (in English, yyyy stands for the year, in German it's jjjj). When the Excel spreadsheet is saved, these formats are stored in the English form so that the sheet can be opened by user's and Excel installations with any language. In your case, internationalization probably affects the date format used when you edit the cell (putting month before day and using 12-hour display with AM/PM looks like Northern America).
I don't quite understand why Excel displays "7/22/2011 12:00:00AM" (instead of "7/22/2011 0:00:00AM"). I'm pretty sure your date/time has a time part of "0:00". But the internal number (as reveal by Value2) will tell you for sure.
It's like a formula, in the cell it will show the result, in the formula bar it will show the formula. The cell you can format, the formula bar you cannot. So you can change the cell's format to however you would like it to look like.
So, if you want to format the msgbox then you would need to do the following:
MsgBox (Format(ActiveWorkbook.ActiveSheet.Cells(x,y), "m/d/yyyy h:mm")