Is there an option on KustoExplorer so I can write my dates with UK format? - kql

Currently when I write dates in Kusto they are in USA format
//1st April 2022
let Date_USA = datetime(04-01-2022);
Is there an option in Kusto Explorer that would allow me to write dates in UK format instead?
//1st April 2022
let Date_UK = datetime(01-04-2022);

Avoid either.
The only place where you should ever use any date format other than ISO (yyyy-MM-dd) is customer facing applications.
ISO is the only format that is not open for interpretation by your software/SDK/OS and is not affected by any configuration settings.
let Date = datetime(2022-04-01);

Related

java.time format date depending on locale with 2 digits day/month and 4 digits year

I need to show a date with 2 digits day, 2 digits month, 4 digits year according to the order of the local. So for April 10th 2020 I want to show
for locale US: MM/DD/YYYY -> 04/10/2020
for locale UK: DD/MM/YYYY -> 10/04/2020
for locale DE (Germany): DD.MM.YYYY -> 10.04.2020
I tried the following without success:
// this one already fails for DE, because it gives 10.04.20 (only 2 digit years)
myDate?.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT))
// works for DE (gives 10.04.2020), fails for UK as is gives 10 Apr 2020 instead of 10/04/2020
myDate?.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM))
So, how can I get a locally adapted date format with only 2 digits day/month and 4 digits year? Please note that I am looking for a general solution, the 3 locales explicitly stated here are just examples.
I am actually using a java.time port for Android (ThreeTenABP), though this shouldn't be relevant.
I am afraid that it will take some hand work. For example, in Java because this is what I can write:
Locale formattingLocale = Locale.getDefault(Locale.Category.FORMAT);
String builtInPattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern(
FormatStyle.SHORT, null, IsoChronology.INSTANCE,
formattingLocale);
String modifiedPattern = builtInPattern.replaceFirst("y+", "yyyy")
.replaceFirst("M+", "MM")
.replaceFirst("d+", "dd");
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(modifiedPattern, formattingLocale);
LocalDate myDate = LocalDate.of(2020, Month.APRIL, 10);
System.out.println(myDate.format(dateFormatter));
Example outputs in different locales:
US: 04/10/2020
UK: 10/04/2020
Germany: 10.04.2020
Swedish/sv: 2020-04-10
Hong Kong/zh-HK: 2020年04月10日 (I got no idea whether this is correct)
Ole V.V.'s answer works from Oreo forwards, but lots of devices are using older versions of Android. The following works in most countries for all Android versions.
This looks hacky, but the official JavaDoc for DateFormat says that casting the format from factory methods to SimpleDateFormat works in majority of countries.
val dateFormat = DateFormat.getDateInstance(DateFormat.SHORT)
if (dateFormat is SimpleDateFormat) {
val adjustedPattern = dateFormat.toPattern()
.replace("y+".toRegex(), "yyyy")
.replace("M+".toRegex(), "MM")
.replace("d+".toRegex(), "dd")
dateFormat.applyPattern(adjustedPattern)
}
You may wrap that in a try-catch-block and do something clever for the few exceptional countries where this doesn't work. Or for them you could just give up and use their default short format. I'm pretty sure humans can understand that format :-D.

I want to create U.S. Date Format to Indian Date Format Using Asp MVC Core 2.0

I am trying to Create Date Format the US to Indian Date Format like(dd/mm/yyyy hh:mm tt).
When I run the code on my local machine it works.
When we publish and fetch values from the server at that time it shows "US" Date Format(mm/dd/yyyy)
How τo do the internal conversion, in Appsettings.json what strings i need to mention.
public static DateTime ConvertIndianDateFormat(DateTime usTime)
{
DateTime dateTime = DateTime.Now;
TimeZoneInfo usEasternZone = TimeZoneInfo.FindSystemTimeZoneById("US Eastern Standard Time");
TimeZoneInfo indianZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
DateTime usEasternTime = TimeZoneInfo.ConvertTimeFromUtc(usTime, usEasternZone);
DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(usTime, indianZone);
return indianTime;
}
This is because you are probably using something like DateTime.Now for C# and if you have an SQL Server you are using GETDATE(). It's not like an issue with application.json or something. The above functions return the machine datetime, thus why locally on your pc the time is correct and incorrect if you upload it to a server.
So make sure that the time is correct. If you are uploading to servers in another country then you will probably have a different time and/or format.
How you proceed depends on your needs:
Is the time correct?
Then simply reformated it or store it specifically using
DateTime.Now.ToString("dd/mm/yyyy hh:mm tt") // this is not the correct format.
Do you want to serve multiple clients in multiple regions/countries?
Then you should store the time as UTC and cast it based on clients date format. For example the server could be in USA and someone from UK would view a different time than his own which would be weird.
DateTime.UtcNow
Generally your problem could be large or small depending on your needs

Swift 3 playground logs dates in local format. How?

If you run a line like this in a Playground in the US:
let today = Date()
You'll see output like this to the right of the source code:
"Sep 26, 2016, 8:17 PM"
That appears to be the date, displayed in the local time zone, using medium date and time style.
How does that work?
If you try to print the date:
print("today = \(today)"
You'll see "Today = 2016-09-27 00:18:55 +0000\n", which is UTC, and appears to be unix date format.
What function is the Playground using to display the date when you first create a date? Is there a way to get to that output format from code or from the debug console?
Up until now I've created a date formatter that I use to log dates, display them in the console, etc.
It's lurking in CustomPlaygroundQuickLookable protocol, which Date conforms to:
if case .text(let str) = today.customPlaygroundQuickLook {
print(str)
}

MS SQL Server - convert(datetime, string, code) -> What code for dd/mm/yyyy hh:mm:ss (24hours)?

I would to CONVERT this string 08/12/2014 16:46:12 to a datetime but I do not know what code to use and it is driving me crazy. I looked on many pages but do not find it
CONVERT(datetime,'08/12/2014 16:46:12',???)
Thank you in advance
Parameter 131 is incorrect, because it uses the Hijri calendar - 2014 becomes 2576.
Use 103 as style parameter instead:
convert(datetime,'08/12/2014 16:46:12',103)
Despite the documentation on http://www.w3schools.com/sql/func_convert.asp it also converts the time value (tested on SQL Server 2014 and 2008 Express).
convert(datetime,'08/12/2014 16:46:12',13)
OR
convert(datetime,'08/12/2014 16:46:12',113)
One Last GO :)
SELECT CONCAT ((convert(datetime,'08/12/2014,103)),' ',(convert(datetime,'16:46:12',114))) AS DateTime
Here is a list of them all http://www.w3schools.com/sql/func_convert.asp

Getting view options in Microsoft Project using VBA

If I want to change the current date format to 20, for example, I can use the command
OptionsViewEx DateFormat:=20
but how can I get the current date format (or any other view option for that matter)?
DefaultDateFormat should be the function to use.
oldvalue = Application.DefaultDateFormat
Application.DefaultDateFormat = 20 ' or = pjDate_mm_dd_yyyy
This gets or sets the default date format. (technet)
This gives the complete list of format types.
If you use Date function get a date in current format, but if you need change use format(Date,"yyyy-mmmm-dd") for example.