The date in reminder is US format ( mm/dd/yyyy) By default I guess. How to manipulate the collection of reminders and format the date to british format so that the listBox will show the reminders as below:
Begin Date ( in British Format or non-US format)
Content
MyReminders = ScheduledActionService.GetActions()
.Where(a => a.BeginTime.Date == Today);
foreach (Reminder r in MyReminders)
{
// How to change the date format to British in each of the reminder and display
in the listBox?
}
ReminderListBox.ItemsSource = MyReminders;
In the list Box :
<ListBox Name="ReminderListBox" Margin="1,116,-2,4" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent" Margin="0,0,0,30">
<StackPanel Orientation="Horizontal" >
<TextBlock Text="begin "/>
<TextBlock Text="{Binding BeginTime}" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>
</DataTemplate/>
</ListBox.ItemTemplate/>
</ListBox />
problems : I dont want to set the date format in the listbox. I want to dynamically detect the locale and display the date Format base on the detected locale Ex Non-US format for Jpn, Kor, China
What does your listbox template look like? You should be able to make it pick the "right" date format for the culture using a format specifier of "d" (for short date) or "D" (for long date) ... and I'd expect you to be able to do that from XAML rather than changing anything else.
Note that the DateTime itself doesn't have a format - so it's not like you could set that value to be "in" UK format.
EDIT: I think you want:
{Binding BeginTime, StringFormat=d}
or if you want to force a specific format (which I don't recommend)
{Binding BeginTime, StringFormat=dd/MM/yyyy}
Related
I have an excel dateset where date column includes date in dd-mm-yyyy format(Proper date) and in text format that too in mm/dd/yyyy format(just text not proper date). want to convert all dates in dd-mm-yyyy format. How to do all in dd-mm-yyyy format in Power Query editor
The question is: In Power Query Editor Perform all necessary action to convert all the dates in the "Date" column to be in "dd-mm-yyyy" format.
I am new in Power BI. Please help on this.
enter image description here
Importing correctly
If you set the right culture, all the inputs are converted to a type date
let
Source = #table(
type table[Date = text],
{ {"7/27/2012"}, {"9/14/2020"}, {"04-11-2020"} }
),
// using the system's current culture
#"Dates" = Table.TransformColumnTypes(
Source,
{ {"Date", type date} }
),
//specify a specific culture
#"US Dates" = Table.TransformColumnTypes(
Source,
{ {"Date", type date} },
"en-US"
)
in
#"US Dates"
date verses text
I'm not clear if you're referring to different date format strings, or actual data types when you say Proper Date, I think you mean the first.
In the query editor where you import dates, it should be type date
If it visually displays out of order, that's okay. It's using your systems current settings.
Once you're in the data model, that is when you pick your date format strings. Notice that both images use the same data, the green is the data type in Power Query.
Blue is the format string that lets you override the defaults.
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);
I'm trying to display a date column in grid like this: "dd-mm-yyyy". In dbf table, the date is stored in this format: "YYYY-MM-DDThh:mm:ss" in a character field.
The grid is created from this cursor:
select id,beginningDate,endDate,cnp from doc ORDER BY id desc INTO CURSOR myCursor
I wish something like this:
select id,convert(beginningDate, Datetime,"dd-mm-yyyy"),endDate,cnp from doc ORDER BY id desc INTO CURSOR myCursor
Fox doesn't have a builtin function called convert(), nor can it handle your non-standard date/time string format directly.
A quick and dirty way to convert a string foo in the given format ("YYYY-MM-DDThh:mm:ss") to a date/time value is
ctot("^" + chrtran(foo, "T", " "))
The caret marks the input as the locale-independent standard format, which differs from the input format only by having a space instead of a 'T'.
You can extract the date portion from this via the ttod() function, or simply extract only the date portion from the string and convert that:
ctod("^" + left(foo, 10))
Fox's controls - including those in a grid - normally use the configured Windows system format (assuming that set("SYSFORMATS") == "ON"); you can override this by playing with the SET DATE command.
There seems to be no mask-based date formatting option as in most other languages. dtoc() and ttoc() don't take format strings, transform() takes a format string but blithely ignores it for date values.
I am with Tamar on this subject, you should have used a datetime field instead.
Since you are storing it like this anyway, you can 'convert' to datetime using the built-in cast function (or ttod(ctot()) in versions older than VFP9 - in either case you don't need to remove T character):
select id, ;
Cast(Cast("^"+beginningDate as datetime) as date) as beginningDate, ;
endDate,cnp ;
from doc ;
ORDER BY id desc ;
INTO CURSOR myCursor ;
nofilter
In grid or any other textbox control, you can control its display style using DateFormat property. ie:
* assuming it is Columns(2). 11 is DMY
thisform.myGrid.Columns(2).SetAll('DateFormat', 11)
I have a vbs file that queries the domain as below
queryTxt = "<"& domainname &">;" & _
"(&(objectclass=user)(objectcategory=person));"
queryTxt = queryTxt & "SAMAccountName,whenchanged"
But in some servers "whenchanged" is returning values as "8/18/2014 1:20:30 AM" and in some as "12-08-2014 04:54:58". I want to have the returning value as the first date format.
How to update the query so that I get a unique date format.
Queries to the whenChanged attribute return a Date value, so the display format is governed by the regional settings of the computer displaying the query results. Either change the date format in the computer's regional settings, or use a StringBuilder object for building a custom date format.
I have a pair of Kendo Datepicker fields on a page for Start Date and End Date. The Start Date defaults to today's date and the End Date defaults to today's date a year from now. The user is allowed to pick a date from the Kendo Datepicker calender or enter a date manually.
The Datepicker calendar popup on the End Date field has a 'max' option set so it won't show dates greater than one year from now, but a user can enter a later date manually. If they do so and click Submit on my form, the server-side validation will catch the problem and display the form again with an error.
I want to leave the date the user manually entered in the Datepicker field intact so they can see the source of the problem, but keep the 'max' option in the calendar. But when I set the Datepicker options with a 'max' and a 'value' that's after the max, it shows the value in the wrong format.
Here's how to replicate:
HTML:
<!-- Note future date in 'value' attribute. -->
<input id='dateField' style="width: 100%;" type="text" value="20160618">
JS:
var dateField = $("#dateField");
// The DatePicker's value comes from the dateField's 'value' attribute.
var value = moment(dateField.val(), 'YYYYMMDD').toDate(); // moment().toDate() gives a JavaScript Date object.
// Initialize the date picker options object with some common settings.
datePickerOptions = {
format: 'MM/dd/yyyy',
value: value,
}
// Set the max to be one year from now.
datePickerOptions.max = new Date(moment(new Date()).add('years', 1).toDate());
// Initialize the DatePicker.
dateField.kendoDatePicker(datePickerOptions);
// Here's a workaround I found... After initializing the picker, manually set the value back to the correctly formatted string.
//dateField.val(moment(value).format('MM/DD/YYYY'));
jsFiddle with the above code.
Set the 'value' attribute of the input tag to be a date after the max date and the date will display like this:
Fri Jun 19 2015 00:00:00 GMT-0700 (Pacific Standard Time)
instead of how it should be:
06/15/2015
Is this a Kendo bug or is it broken by design? Or am I goofing up somewhere?
Yeah, it looks like the control is working fine. The issue is that the control fails fast on testing for max, which means it doesn't apply some other options (eg. format). I'd vote for broken by design.
try this...
datePickerOptions = {
format: 'MM/dd/yyyy',
value: moment(value).format('MM/DD/YYYY'),
max: new Date(moment(new Date()).add('years', 1).toDate())
}