How do I keep the date in a formula? - excel

I'm attempting to create a date range in a merged cell with the following:
=(A1-1) & "-" & (A1-6)
So I'm referencing a date that I have in a cell (A1) and subtracting a few days from it. Once I try to do this it returns the following:
41914-41909
I'd like to be able to keep the dates in the following format:
1/1/2014 - 1/7/2014
How would I do this?

You just need to convert the dates to text before trying to concatenate them as a string.
=TEXT(A1-1, "mm/dd/yyyy") & " - " & TEXT(A1-6, "mm/dd/yyyy")
Here's a similar question on StackOverflow: Convert date field into text in Excel. It gives a little more detail if you have any problems.

Related

Calculate total work days in a month using the month name

I am trying to write a formula that will count all the work days in a month based on the month name. I am having a hard time trying to find information through Google on how to solve this without installing a 3rd party plugin, or writing it in VBA.
My table looks like this:
And the formula I am playing around with looks like this
=NETWORKDAYS.INTL(MONTH(A2),MONTH(A2),17)
Since it looks like the month name is a string Month(A2) will return an error. to get a date you will need to create a full string that Excel can use to return a date:
DATEVALUE("1 " & A2 & YEAR(TODAY()))
Using that and EOMONTH for the end date we get:
=NETWORKDAYS.INTL(DATEVALUE("1 " & A2 & YEAR(TODAY())),EOMONTH(DATEVALUE("1 " & A2 & YEAR(TODAY())),0),17)

Excel date functions

I'm trying to get the current year/month/day military time in a cell. This is exactly what I need in the cell #Date:2017/AUG/14 14:55:08 I know this is super easy to do but I'm just not getting the result that I want. This is what I tried.
="#Date"=date(yyyy,MMM,D, hh:mm)
If you're after VBA:
="#Date:" & Format(now(),"yyyy/MMM/D hh:mm:ss")
If you're after a cell formula:
="#Date:" & TEXT(NOW(),"yyyy/MMM/D hh:mm:ss")
Note: Consider DD instead of D if you want day 1 to read 01 instead of 1
Just enter:
=NOW()
in a cell and custom format as "#Date:"yyyy/mmm/dd hh:mm

Convert "flat" datetime using Excel's format options

I have received an Excel file that contains a number of datetime fields in the following "flat" format:
20150901120844
I need to convert this to a more useful value such as "2015-09-01 12:08:44" using Excel's formatting options.
How can I achieve this?
There is no formatting option that will adjust your dates for you, in this case.
But you can use a formula in an adjacent cell to reorganize the data into the date / time text you desire.
Let's say that 20150901120844 is in cell A1. Then in B1 you could enter this formula:
=LEFT(A1,4) & "-"& MID(A1,5,2) & "-"& MID(A1,7,2) & " "& MID(A1,9,2) & ":"& MID(A1,11,2) & ":"& MID(A1,13,2)
It will result in this value in cell B1: 2015-09-01 12:08:44.

How to change a date type to short date

How would you change this date type Monday, 31, August2015 at 6:08 AM to short date in Excel 31/08/2015 ?
Currently I use Text to Columns on the top date, find and replace to remove the comma on 31,. Then use a combination of =text(1,"00") and =month(A1&1 to format the numbers correctly and finally =concatenation() to join them all together.
This is time consuming and concatenated dates are in a different format to short date formats. When uploading data the software will see them as such.
I'm hoping there is a really easy way of doing this to save time.
It's a long formula, but it works. Before using it make sure you set the Number Formatting for the formula cell to the short date that you want.
Assuming that your awkward date is in cell A1, enter this formula in another cell:
=DATEVALUE(VALUE(SUBSTITUTE(MID(MID(A1,FIND(" ",A1)+1,99),1,2),",","")) & " " & MID(A1,FIND("|",SUBSTITUTE(A1," ","|",2))+1,3) & " " & MID(A1,FIND("|",SUBSTITUTE(A1," ","|",3))-4,4))

Concatenation of string in excel having today() function

In a cell in excel i want to concatenate a string that contain format as below ---
Brett201505LeeMay15
I am trying to do that by today function like -
= "Brett" & Today() & "Lee" & Today()
issue is how to specify date format as "yyyymm" and "mmmyy" in a single cell.
Write now when the cell format is general i am getting some number. I guess it is datevalue. Please help.
Use this expression :
="Brett"&TEXT(TODAY(),"yyyymm")&"Lee"&TEXT(TODAY(),"mmmyy")

Resources