Concatenate DateTimePicker in VS2010 - visual-studio-2010

How can I concatenate the values of two datetimepicker?
DateTimePicker1 - this is for the the DATE mm/dd/yyyy
DateTimePicker2 - this is for the the TIME hh:mm:ss
I want a value of ... mm/dd/yyy hh:mm:ss in one variable, how can I do that?

One easy way would be
DateTime dt = new DateTime(dtp1.Year, dtp1.Month, dtp1.Day, dtp2.Hour, dtp2.Minute, dtp2.Second);
Please check the order of the parameters, I am writing from memory.
Here dtp1 is a DateTime object from the first datetime picker.

Related

How to format date string with date-fns without timezone transformation?

I have really simple date as string as ISO const mytDate = '2021-10-24T16:00:00.000Z' and I want to format it like format(new Date(myDate), 'yyyy-MM-dd HH:mm:ss') but new Date() cause that it convert it to my local timezone and I do not want it. I would like to take this string date and just format it as it is.
Is there a solution ?
Cheers!

Using Carbon I got "textual month could not be found" error

In my Laravel 5.8 application, I to convert date in string format like
02 May, 2019 to date time using Carbon. I try like :
setlocale(LC_TIME, 'en');
$filter_check_in_datepicker_till = Carbon::createFromFormat( 'dd MMMM YYY', $filter_check_in_datepicker_till )->locale('en_EN');;
But got error:
"message": "Unexpected data found.\nA textual month could not be found\nData missing",
Which is right way?
Thanks!
The Carbon docs say:
createFromFormat() is mostly a wrapper for the base php function DateTime::createFromFormat.
It isn't entirely clear from the docs, but that means the $format parameter passed to createFromFormat() is a DateTime format, not a Carbon format. So instead of dd MMMM YYY, you should use d, M Y (check the DateTime format reference):
\Carbon\Carbon::createFromFormat('d, M Y', '02, May 2019');
// returns 2019-05-02 12:48:26
For reference, there are several problems in your Carbon format, so even if createFromFormat took a Carbon format string what you have would not work. Checking the Carbon format reference:
dd is actually "Minified day name (from Su to Sa), transatable". You really want DD for the zero-padded day of month;
The date format you are using includes a comma, but your format string is missing that;
YYY is not actually a valid Carbon format string. You really wanted YYYY for 4-digit year;

Lotus sorting view on orderdate does not work properly

I have created a view in which I also have a column which holds dates. This column can be sorted on ascending and descending. This is my column properties value:
But the problem is that the view does not sort the dates properly:
And here a screenshot of the orderdate field itself:
And here screenshot of the document with the orderdate that is out of order in the view:
Update
Some documents had the orderdate as text instead of date.. I create these documents through a java agent. The field orderdate I fill in like this:
SimpleDateFormat formatterDatumForField=new SimpleDateFormat("dd-MM-yyyy");
docOrder.replaceItemValue("Orderdatum",formatterDatumForField.format(currentDateForField));
But it is saved as text instead of date. Anyone knows why?
Problem was that orderdate field was set by a backend agent and this field was set with a string.
I know saved the current time as a DateTime object and now it works:
DateTime timenow = session.createDateTime("Today");
timenow.setNow();
docOrder.replaceItemValue("Orderdatum", timenow);
It's not clear to me why it's not working for you, but you can brute force it with something like this in the column formula
dateForSure := #TextToTime(OrderDatum);
#Text(#Year(dateForSure)) + "-" + #Text(#Month(dateForSure)) + "-" + #Text(#Day(dateForSure));
Also: your Java code saves a text value because the format() method of SimpleDateFormat returns a StringBuffer. The ReplaceItemValue method generates a text item when its input is a String or StringBuffer. Assuming your form defines OrderDatum as a Time/Date field, you can call Document.ComputeWithForm in your code to force it to convert the text item to a Time/Date. Another method - probably preferable given the potential side-effects of calling ComputeWithForm would be to create a DateTime object in your Java code and pass it to the ReplaceItemValue method instead.
It's because formatterDatumForField.format(currentDateForField) returns a String instead of a date/time value. Assuming that currentDateForField is a date/time value, you should change
SimpleDateFormat formatterDatumForField=new SimpleDateFormat("dd-MM-yyyy");
docOrder.replaceItemValue("Orderdatum",formatterDatumForField.format(currentDateForField));
to
docOrder.replaceItemValue("Orderdatum",currentDateForField);

What does this d3 time format function mean?

I know there is a specified d3 time formatting. But when I check the example shown here d.Year = new Date(d.Year,0,1); the year's format is "1996"
Does it one of the other ways to format year as a string here, i don't quite understand it.
Also, if my time format is like"01/01/96", what is the right format to get the string here?
This isn't a d3 date formatting function. Its one of the basic forms of the Javascript Date constructor.
Specifically, it is using the multi-parameter form of the constructor:
new Date(year, month, day, hour, minute, second, millisecond);
except that all the time parameters are left as their default (0/midnight) values. If the original value for d.Year is the string "1996", the line
d.Year = new Date(d.Year,0,1);
creates a new Date object with year 1996 (the conversion from string to number will be automatic), month value zero (January), day value 1, and time midnight.

updating time of datetime field using linq

I have two fields in my database for storing starttime and endtime. they are of datetime. I pick time from them using tostring("hh:mm tt"). Now I want to update only the time part of the date. I have dropdownlist to select hour and minutes and AM/PM. How can I update the time of date stored in sql server using Entity framework / LINQ in MVC3 application.
Please suggest
actually you don't really need to touch the linq part of this, basically what you want to do is just to convert the string back to a datetime object and just manipulate the datetime object by either creating a new datetime object or add/minus mm/dd/yy hours or minutes.
You must always update the whole datetime - it means you must build a new DateTime in your application and use correct Date part and defined Time part.
create new DateTime Object
DateTime mydate = New DateTime(2011, 6, 1, 12, 30, 0);
or
DateTime mydate = DateTime.Parse("2011-06-1 12:30:00 PM");

Resources