Convert number to month name? - excel

I have this formula:
DQ11=DATE("20"&LEFT(DN18;2);1;-2)-WEEKDAY(DATE("20"&LEFT(DN18;2);1;3))+RIGHT(DN18;2)*7
which gives the number 41519.
For reference:
DN18 = 1336
Now I want to convert 41519 to a month name. How do I do that? I've tried:
=TEXT(DQ11;"mmm")
but it returns 00.

Apparantly Text(DQ11;"MMM") gives me what I want.
I don't know why mmm didn't work and hope that my code will work on other vesions of Excel.

Related

Extracting decimal from time

I have Date and Time in one cell and I need to extract the decimal that excel uses for the time so that I can subtract time from that.
A cell has this value: 01.09.2020 7:01:21
I need to get the time 7:01:21
and then I need to extract the decimal which represents it, that is: 0,292604166666667 and store it in a variable in vba
I searched the internet extensively but everyone wants to do exactly the opposite and I am totally clueless.
Thank you for your help
Ok, I worked it out.
I am not entirely happy with the solution but it works. I am sure some of you guys can come up with a more elegant solution without having to use the variable.
Mine is this:
Dim NumericTime as Double
NumericTime = TimeValue("A1")
Debug.Print NumericTime
With data in A1, in C1 enter:
=TIMEVALUE(MID(A1,FIND(" ",A1)+1,99))
To extract a decimal, simply:
=MOD(A1,1)
Be sure to format the results as General or as Number with an appropriate number of decimal places
In VBA, the Mod function doesn't work with decimals, so the equivalent might be:
Function DecimalTime(tm As Date) As Double
DecimalTime = tm - Int(tm)
End Function

How to parse string timestamp into date

I have a text value that looks like this: 2019-03-25T06:05:00-07:00. The general format is yyyy-mm-ddThh:mm:ss-GMT. I don't care about the GMT part. I am trying to use this text field to make time series scatter plots in excel.
I want to convert it to a timestamp as simply as possible. I currently do this using a bunch of formulas:
Input: 2019-03-25T06:05:00-07:00
Extract parts of time individually: =value(mid(input_cell,12,2))
Use date() and time() to get timestamp types
Add them together per this answer: https://stackoverflow.com/a/41164517/11163122
Use custom formatting to get a timestamp value
Output: 3/25/2019 6:05:00 AM
In total this took me 8 cells and custom formatting. This is too complicated. What is a simpler/more elegant way to do this?
You can use:
=--REPLACE(LEFT(A1,19),11,1," ")
and format as desired
Turns out the timestamp type is ISO 8601: https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
This led me to this answer: https://stackoverflow.com/a/26315881/11163122
Using the formula there, I found this to be a sufficient solution. If anyone out there has a better method, please speak up! :)

How to make Excel recognise Dukascopy date time format

I'm working with a date and time format from the Dukascopy csv download format. It looks like this:
01.03.2018 07:00:00.000 GMT-0000.
Is there a formula to convert this to a format that could be sorted chronologically? I don't need the -0000, just the date and time. Thank you.
Please try:
=DATE(MID(A1,7,4),MID(A1,4,2),MID(A1,1,2))+TIMEVALUE(MID(A1,12,12))
with formatting to suit.
Switch around the second and third parameters of DATE (the 4 and the 1) to suit the date convention of your source, if required.
try this:
=--SUBSTITUTE(LEFT(A1,20),".","/")
Then format as desired.
This only works if the input and the local settings agree as to order of MM/DD or DD/MM.

how to work with uneven dates in Excel?

I needed help as I am trouble with this recurring problem.
I have following date formats. American date format:
8/30/2013
11/1/2014
1/12/2014
For 8/30/2013 , I write =DATE(RIGHT(B2;4);LEFT(B2;1);MID(B2;3;2)), and I get it as "2013-08-30". For the other dates, I have to manually rewrite them again and again.
How can I write in one line to get 8/30/2013 or 10/12/2014 in a final date result like "2013-xx-xx?
if all entries are dates, you can use Text function:
=TEXT(B2, "yyy-mm-dd")
hope this helps.
Since you used string manipulation formulas and it worked for your first date, I believe that the date is actually text format.
As such, I would suggest using FIND to get the positions of / like this:
=DATE(RIGHT(B2;4);LEFT(B2;FIND("/";B2)-1);MID(B2;FIND("/";B2)+1;FIND("/";B2;FIND("/";B2)+1)-FIND("/";B2)-1))
It's quite long, I admit, but it's quite difficult to get substrings between two specific characters. If the year is always in that format, then you can use a slightly shorter formula:
=DATE(RIGHT(B2;4);LEFT(B2;FIND("/";B2)-1);MID(B2;FIND("/";B2)+1;LEN(B2)-5-FIND("/";B2)))

Problems changing date format of date as string

I am currently trying to convert yyyymmdd type of date to a ddmmyyy format.
I've tried using DATE function and something like this:
=DATE(LEFT(A3;4);MID(A3;5;3);RIGHT(A3;7))
Original date for this function is 20120401 but the formula returns: 16.12.2104.
I've tried using functions YEAR, MONTH and DAY instead of LEFT, MID and RIGHT but that's not the right way.
I also tried using DATEVALUE but since Excel probably doesn't recognize yyyymmdd as a date, it gives me a #VALUE! error.
I've found a couple of solutions for SQL but it isn't my strong side yet - and this should be achievable easily in Excel.
Is there a way to do this in Excel?
Applying =DATE(LEFT(A3;4);MID(A3;5;3);RIGHT(A3;7)) to 20120401 in A3 is effectively to reassemble the component characters as below on the left:
These effectively become converted as on the right.
The solution was simply to exclude the digits highlighted red with:
=DATE(LEFT(A3;4);MID(A3;5;2);RIGHT(A3;2))
but the locale might have been a factor and when dealing with date serial numbers and/or what appears to be a date but is a string various other issues might have been involved.
Consider:
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))

Resources