Excel download date format changing in different time zone - asp.net

How, i can keep date format same of excel at the time of download in different-2 time zone?
My downloaded file contains date column format is MM-dd-YYYY.
The issue is that, while i am downloading the excel file in US region it is not converting the dates into different formats, while i am downloading the same file in UK region, it is converting the dates into dd-MM-YYYY.
Date 12-01-2015 is converting to 01-12-2015.
I want to keep date format of excel file MM-dd-YYYY in all the regions.
I am generating the file using ASP.Net C#.
Thanks in advance.

This is because Excel is selecting the different date format based on the program's locale setting. I would imagine your options are:
a: Change the cell format to what you need in each location, e.g. in VBA the code would be something like Selection.NumberFormat = "m/d/yyyy;#"
b: Store your date data in text format. So literally a text string in mm-dd-yyyy format. You could still easily parse it later.

Related

Importing dates from excel (some formatted as dates some as numbers)

I am working an uploaded document originally from google docs downloaded to an xlsx file. This data has been hand entered & formatted to be DD-MM-YY, however this data has uploaded inconsistently (see example below). I've tried a few different things (kicking myself for not saving the code) and it left me with just removing the incorrectly formatted dates.
Any suggestions for fixing this in excel or (preferably) in R? This is longitudinal data so it would be frustrating to have to go back into every excel sheet to update. Thanks!
data <- read_excel("DescriptiveStats.xlsx")
ex:
22/04/13
43168.0
43168.0
is a correct date value
22/04/13
is not a valid date. it is a text string. to convert it into date you will need to change it into 04/13/2022
there are a few options. one is to change the locale so the 22/04/13 would be valid. see more over here: locale differences in google sheets (documentation missing pages)
2nd option is to use regex to convert it. see examples:
https://stackoverflow.com/a/72410817/5632629
https://stackoverflow.com/a/73722854/5632629
however, it is very likely that 43168 is also not the correct date. if your date before import was 01/02/2022 then after import it could be: 44563 which is actually 02/01/2022 so be careful. you can check it with:
=TO_DATE(43168)
and date can be checked with:
=ISDATE("22/04/13")

WP All Import date issue

I am importing an excel file that has a date field with the following format: dd/mm/YYYY
It imports the data OK, however it does something strange with the dates. If the day is higher than 12, then it takes the current date.
I found this on the log:
WARNING: unrecognized date format ``, assigning current date
For example: the date 08/04/2020 is imported ok because 08 <= 12, however the date 23/02/2020 is not imported because 23 is not <= 12, and then it takes the current date.
Any ideas about what is happening?
This issue can get confusing with Excel, since typically, if the system is set for U.S. locales, Excel converts standard European date format in day-month-year to some version of month/day/year. In other words, tThe forward slash usually indicates American format, which is month first, as in April 9, 2022 or 04/09/22. You can force day/month/year, and apparently that was done for your file or system, but that's not an expected or standard format.
Without examining All Import code in detail, I'd say the behavior you describe implies it is presuming the standard usage. I'd therefore recommend that you try converting your date column before attempting imports, but how to do that efficiently would probably be more an Excel question than a WordPress question, unless you are able in your version of All Import to perform a custom conversion on the field.
A trick that sometimes works on this type of problem is copy-pasting Excel data into a Google Sheet, then downloading as CSV, without ever opening the file in your system before re-uploading. Google Sheets is pretty good about such conversions in general, but no guarantees: Your source file might defeat it in this case.
I had the same issue. Change the dates in your csv file to mm/dd/yyyy and when it imports it will automatically convert to dd/mm/yyyy if that is what your WP website is set up to use.
Only numbers lower than 12 will work the way you are importing because there are only 12 months in a year and it is reading you dd as mm.

Messy dates after importing from Excel into R

I have trouble reading in a date column in the correct format after importing an excel file.
If I format the Date column to character, some dates appear messy - like 44655, 44565, 31/03/2022, 30/03/2022...
However, if I format the Date column as a date, there are some NA values.
What is the problem? How can I reformat all values in the Date column in d/m/y?
This normally occurs if you have entered dates into your excel spreadsheet in multiple formats. I suspect on your excel spreadsheet, sometimes you have the date formatted as a date, and other times, the date is formatted as text. In my experience, its simplest when you have the date entered in excel as text.
If you go in excel, and change the column format to text, you will see the entries that are mixed.

How to stop R from automatically converting string to date?

I have a large excel file I'm reading into R for a sports analytics project. One of the columns is height, and the format in excel is ft-in (i.e. 5-10). This is fine in excel because that column was specifically formatted to take in plain text and not convert it to date. But when I read the csv to R, the data frame auto converts to date. Is there a command/parameter to have it not do this?

What is the correct date format for writexl

What is the correct date format for the new writexl package? I tried it on lubridate dates, and the resulting Excel spreadsheet contains strings of the form yyyy-mm-dd (i.e. not Excel dates).
The purpose of the writexl package is to essentially create a mirror image of an R table in an excel file format. So having data in one of the usual R date/time formats like as.Date, as.POSIXct, etc. won't translate to a date format shifting from YYYY-mm-dd to d/m/y while being exported to excel. If you'd like it in a more standard excel date/time format in the excel file, it's best to convert it prior to exporting it with something like the strftime() function, like this:
require(writexl)
write_xlsx(
data.frame(date=strftime(c("2017-09-10","2017-09-11","2017-09-12"),"%d/%m/%y")),
"~/Downloads/mydata.xlsx")
Output (in xlsx file):
date
10/09/17
11/09/17
12/09/17
Edit:
If you'd like the data to be an Excel date format once it's in the new file, then adding as.POSIXct() to the above will ensure that.
It worked when I converted my dates to POSIXct dates using as.POSIXct.

Resources