I download invoice reports from my magento website. They hold a date format I am not able to change to a standard date format. This is what it looks like: 1 aug. 2016 15:24:08
What formula can I use to have excel change it to a format like 13-08-16 (Dutch Format) ( I don't need the time for the moment).
Assuming that your 3 letter month names end with a dot in magneto data, you can use this where original data is in cell A1
=TEXT(SUBSTITUTE(LEFT(A1,FIND(".",A1)+5),".",""),"dd-mm-yy")
Check if "1 aug. 2016 15:24:08" is:
a\ pure string (String Type data; "wroted" date)
or
b\ string representation of Date type data (formatted date)
.
Related
How can date in the US format dd-mmm-yyyy be converted to a date in European format.
When importing text based data with US Dates, some dates will import as a date, some import as a string.
A US date like 11-Jun-2021 is equal to NL format, so it will import as a date.
A US date like 11-Oct-2021 should be converted to 10-okt-2021, but it's imported as a string.
Is there a way to convert this string to a date format?
Found something. It's kinda dirty, but it works:
=IF(C3=0;"";IF(IFERROR(FIND("Oct";C3;1);FALSE);REPLACE(C3;FIND("Oct";C3;1);3;"Okt");IF(IFERROR(FIND("May";C3;1);FALSE);REPLACE(C3;FIND("May";C3;1);3;"Mei");IF(IFERROR(FIND("Mar";C3;1);FALSE);REPLACE(C3;FIND("Mar";C3;1);3;"Mrt");C3))))
This works for me in Italian. A3 contains the original date (only 8 months need to be translated):
=IF(ISNUMBER(A3);A3;1*SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A3;"Jan";"GEN");"May";"MAG");"Jun";"GIU");"Jul";"LUG");"Aug";"AGO");"Sep";"SET");"Oct";"OTT");"Dec";"DIC"))
i have do the research all over the internet but most of the references is about dd/mm/yy or dd.mm.yy but i want something like dd mmmm yyyy (between are using space)
and i have tried to used
=MID(A1,SEARCH("?? ????? ????",A1),13)
to extract the date from the text string but it will error in some cell such as display the text not date.
my date will be in 2 type below:
on (1 April 2020)
on 1 April 2020
if on has CONCAT and FILTERXML:
=CONCAT(IFERROR(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,")",""),"(","")," ","</b><b>")&"</b></a>","//b[starts-with(following::*[1],"&{"'Jan'","'Feb'","'Mar'","'Apr'","'May'","'Jun'","'Jul'","'Aug'","'Sep'","'Oct'","'Nov'","'Dec'"}&")]"),""))&" "&CONCAT(IFERROR(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,")",""),"(","")," ","</b><b>")&"</b></a>","//b[starts-with(.,"&{"'Jan'","'Feb'","'Mar'","'Apr'","'May'","'Jun'","'Jul'","'Aug'","'Sep'","'Oct'","'Nov'","'Dec'"}&")]"),""))&" "&CONCAT(IFERROR(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,")",""),"(","")," ","</b><b>")&"</b></a>","//b[starts-with(preceding::*[1],"&{"'Jan'","'Feb'","'Mar'","'Apr'","'May'","'Jun'","'Jul'","'Aug'","'Sep'","'Oct'","'Nov'","'Dec'"}&")]"),""))
Note: this returns the string. If one wants a true date then:
=--(CONCAT(IFERROR(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,")",""),"(","")," ","</b><b>")&"</b></a>","//b[starts-with(following::*[1],"&{"'Jan'","'Feb'","'Mar'","'Apr'","'May'","'Jun'","'Jul'","'Aug'","'Sep'","'Oct'","'Nov'","'Dec'"}&")]"),""))&" "&CONCAT(IFERROR(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,")",""),"(","")," ","</b><b>")&"</b></a>","//b[starts-with(.,"&{"'Jan'","'Feb'","'Mar'","'Apr'","'May'","'Jun'","'Jul'","'Aug'","'Sep'","'Oct'","'Nov'","'Dec'"}&")]"),""))&" "&CONCAT(IFERROR(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,")",""),"(","")," ","</b><b>")&"</b></a>","//b[starts-with(preceding::*[1],"&{"'Jan'","'Feb'","'Mar'","'Apr'","'May'","'Jun'","'Jul'","'Aug'","'Sep'","'Oct'","'Nov'","'Dec'"}&")]"),"")))
And format the date as desired.
I have a number of excel strings in the format "Mon Nov 25 17:20:47 +0000 2019"
I found an earlier post that recommended using =DATE(RIGHT(O2,4),MONTH(DATEVALUE(1 & MID(O2,5,3))),MID(O2,9,2)) to create a usable date field. However, this drops the time which is an important piece of information.
How can I include the time with the date in order for excel to recognize and sort all the information included in the field?
Thank you in advance!
You can just use the same logic with the date formula, but use TIME instead of DATE and of course extract the correct time into the formula =TIME(MID(O2,12,2),MID(O2,15,2),MID(O2,18,2))
Edit:
to combine them both in one field, you will need to add them =DATE(RIGHT(O2,4),MONTH(DATEVALUE(1 & MID(O2,5,3))),MID(O2,9,2)) + TIME(MID(O2,12,2),MID(O2,15,2),MID(O2,18,2))
The rationale of this is because:
Date is expressed in whole numbers i.e. 1 = 01/01/1900, 2 = 02/01/1900, 3 = 03/01/1900... 43794 = 25/11/2019, etc.
Time is expressed as a fraction of the day i.e. 0.5 = 12 hrs/12PM, 0.66666 = 16 hrs/4PM, etc.
so lets say you have 1/1/2019 12.00 PM, the date part that gives 1/1/2019 will be 43466 and the time part will be 0.5. Adding them together will give you 43466.5, and when converted to a date time format it will show as 1/1/2019 12:00 PM.
You can use string functions to create an unambiguous date string, then turn it into a date/time value with a mathematical operation (adding the time value in a string form).
=(MID(A1,9,2)&"-"&MID(A1,5,3)&"-"&RIGHT(A1,4))+MID(A1,12,8)
You'll need to format the result as something appropriate: eg: dd-mmm-yyyy hh:mm
I'm using today to aquire todays date and then adding a static value to the end of it using the following:
=TODAY()&"T23:00:00"
Which Returns 43202T23:00:00
I really need it in the format 2018-04-12T23:00:00
Any help on this would be great!
There are a couple ways to accomplish this, depending on whether your goal is a formatted String (to display) or a numeric value (such as data type Date) for storing or using with calculations.
If you want a formatted date/time result (to display to the user)...
Use the TEXT worksheet function:
=TEXT(TODAY(),"yyyy-mm-dd")&"T23:00:00"
...the reason this works is because TODAY() returns a Date data type, which is basically just a number representing the date/time, (where 1 = midnight on January 1, 1900, 2 = midnight on January 2, 1900, 2.5 = noon on January 2, 1900,etc).
You can convert the date type to a String (text) with the TEXT function, in whatever format you like. The example above will display today's date as 2018-04-12.
If, for example, you wanted the date portion of the string displayed asApril 12, 2018 then you would instead use:
TEXT(TODAY(),"mmmm d, yyyy")
Note that the TEXT worksheet function (and VBA's Format function) always return Strings, ready to be concatenated with the rest of the String that you're trying to add ("T23:00:00").
If you want to use the result in calculations...
If you instead want the result to be in a Date type, then instead of concatenating a string (produced by the TEXT function) to a string (from "T23:00:00"), you could instead add a date to a date:
=TODAY()+TIME(23,0,0)
or
=TODAY()+TIMEVALUE("23:00")
..and then you can format it as you like to show or hide Y/M/D/H/M/S as necessary with Number Formats (shortcut: Ctrl+1).
More Information:
MSDN : TEXT Function (Excel)
MSDN : TIMEVALUE Function (Excel)
MSDN : TIME Function (Excel)
I have imported an excel sheet where the date1 is 4/1/16 date2 is 5/29/14 and date3 is 5/2/14. However, when I import the sheet into SAS and do PROC PRINT gives the first 2 variable columns as "42461" and "41788" while the date3 is 05/02/2014.
I need these date formats consistent b/c I am doing a Cox regression with PROC PHREG.
Any thoughts about how to make these dates consistent?
Thanks!
This probably depends on how the data is represented in Excel and how it is imported into SAS. First, are the formats the same in Excel? The first two are being imported as a number. The second as a string.
In Excel, you can format the column using a date format. Perhaps your import method will recognize this. You can also define another column as a string, using the text(<whatever>, "YYYY-MM-DD") to convert to a string in that format.
Alternatively, you can import all as numbers and then add the value to 1899-12-31. That is the base date for Excel. This makes more sense if you think of "1" as being 1900-01-01.
Because your column had mixed numeric (date) and character values SAS imported the field as character. So the actual dates got imported as the text version of the actual number that Excel stores for dates. The ones that look like date strings in SAS are the fields that were strings in Excel also.
Or if in your case one of the three columns was all valid dates then SAS imported it as a number and assigned a date format to it so there is nothing to fix for that column.
The best way to fix it is to make sure that all of the values in the date column are either real dates or empty cells. Then PROC IMPORT will be able to make the right guess at how to import it.
Once you have the strings in SAS and you want to try to fix them then you need to decide which strings look like integers and which should be treated as date strings.
So you might just check if they have any non-digit characters and assume those are the ones that are date strings instead of numbers. For the ones that look like integers just adjust the number to account for the fact that Excel numbers dates from 1900 and SAS numbers them from 1960.
data want ;
set have ;
if missing(exel_string) then date=.;
else if notdigit(trim(excel_string)) then date=input(excel_string,anydtdte32.);
else date=input(excel_string,32.) + '01JAN1900'd -2 ;
format date yymmdd10. ;
run;
You might wonder why the minus 2? It is because Excel starts from 1 instead of 0 and also because Excel thinks 1900 was a leap year. Here are the Excel date numbers for some key dates and a little SAS program to convert them. Try it.
data excel_dates;
input datestr :$10. excel_num :comma32. #1 sas_num :yymmdd10. ;
diff = sas_num - excel_num ;
format _numeric_ comma14. ;
sasdate1 = excel_num - 21916;
sasdate2 = excel_num + '01JAN1900'd -2 ;
format sasdate: yymmdd10.;
cards;
1900-01-01 1
1900-02-28 59
1900-03-01 61
1960-01-01 21,916
2018-01-01 43,101
;