Converting integer to time format in excel - excel

Date
19112018
19112016
19112015
19112013
I have a column named Date.
I want to convert 19112018 to 2019-11-20 18:00
19 means year 2019
11 month
20 days
18 is hour
Thanks .

Use the following formula:
=DATE(20&LEFT(A2,2),MID(A2,3,2),MID(A2,5,2))+RIGHT(A2,2)/24
Or:
=--(20&REPLACE(REPLACE(REPLACE(A2,7,0," "),5,0,"-"),3,0,"-")&":00")
Then format the output cell:
yyyy-mm-dd hh:mm

Related

Excel remove timestamp from date and subtract days

So I have a column say Date1 which has date in datetime stamp. I want to subtract 10 days from Date1 column and keep in another column say Date2. I only want to subtract ten days from date not from datetime.
How to remove the time stamp. Read many solutions online but could not find for excel
Input table
Date1
26-03-2000 21:00:00
25-04-2000 00:00:00
21-03-2000 01:00:00
31-03-2000 13:00:00
05-03-2012 12:00:00
Expected output
Date1 Date2 Date1_no_timestamp
26-03-2000 21:00:00 16-03-2000 26-03-2000
25-04-2000 00:00:00 15-04-2000 25-04-2000
21-03-2000 01:00:00 11-03-2000 21-03-2000
31-03-2000 13:00:00 21-03-2000 31-03-2000
05-03-2012 12:00:00 24-02-2012 05-03-2012 and so on
You could use the TEXT() function.
=TEXT(B2, "DD-MM-YYYY")
Alternatively, as the above solution could cause issue based on timezone formatting, you could remove anything past the first space:
=LEFT(B2, FIND(" ",A2,1)-1)
Place either the following in C2 (assuming those headers exist) and drag down.
You could use:
Method 1:
Date1_no_timestamp:
=TEXT(A2,"dd-mm-yyyy")
Date2:
=TEXT(A2-10,"dd-mm-yyyy")
Method 2
Date1_no_timestamp:
=RIGHT("0"&DAY(A2),2)&"-"&RIGHT("0"&MONTH(A2),2) & "-" & YEAR(A2)
Date2:
=TEXT(DATEVALUE(E2)-10,"dd-mm-yyyy")
Results:
You can also use the INT() and TRUNC() functions:
=INT(A2)
=TRUNC(A2)
Their behavior is identical for positive numbers - the decimal part is sliced off.

Convert sting in datetime like excel format cell does in t-sql

I have END_Date data like 43830.99931. When I paste it in the excel and format the cell to Date. It convert it to 12/31/2019 11:59:00 PM. I want same functionality in T-SQL. How can I achieve same result using T-SQL?
Excel (by default) uses the 1900 date system. This simply means that the date 1 Jan 1900 has a true numeric value of 1, 2 Jan 1900 has a value of 2 etc. These values are called "serial values" in Excel and it is these serial values that allows us to use dates in calculations.
The code to convert:
DECLARE #SerialDate FLOAT;
SET #SerialDate = 43830.99931;
SELECT CAST(#SerialDate - 2 AS DATETIME);
returning back the date time value of:
2019-12-31 23:59:00.383
You may have noticed the -2 in the cast. That's because Excel, due to issues with 29th Feb 1900 and the inclusiveness of the start/end dates. (1900-01-01 is day 1 not day 0, and 1900 was not a leap year but excel calculates it wrongly) we have to subtract 2. Details on that issue can be found here.

Calculate in Excel Sum of Days given 2 date ranges (Start date , End date), aggregate monthly

Please find the excel data.
Input format:
ID Begin Date End Date Comment
1 07/25/17 08/16/17 July 6 days, August 16 days
2 05/01/17 05/11/17 11 Days in May
3 07/10/17 07/16/17 6 days in July
Output format:
Jan-17 Feb-17 Mar-17 Apr-17 May-17 Jun-17 Jul-17 Aug-17..... Dec
11 12 16
How to get this aggregate at month level, given a range
Input Format:
Output format:
Are you including start date and end date because your results aren't consistent. If ID2 is 11 days then shouldn't ID3 be 7?
Assuming that you want to include both start date and end date then you can do that like this:
Put the first of each month in A8 copied across (formatted as mmm-yy) then use this array formula in A9
=SUM(TEXT(IF($B2:$B4="",0,IF($C2:$C4>EOMONTH(A8,0),EOMONTH(A8,0),$C2:$C4)-IF($B2:$B4<A8,A8,$B2:$B4)+1),"0;\0")+0)
confirm with CTRL+SHIFT+ENTER and copy across
This only counts rows that have both start and end date
See screenshot:

Transform text-date in format

I have a text formatted date that looks like this:
June 12th 2017, 9:07am PDT
How can I transform it in a date format (the classic methods Format Cells and DateValue() don't work)?
Thank you.
My solution uses a helper table listing all the 12 months and their serial number at A1:B12
January 1
February 2
March 3
April 4
May 5
June 6
July 7
August 8
September 9
October 10
November 11
December 12
Assuming the value is in D10
Getting the separate elements
Month:
=VLOOKUP(LEFT(D10,FIND(" ",D10)-1),A1:B12,2,FALSE)
Date:
=IFERROR(VALUE(RIGHT(LEFT(D10,FIND(" ",D10)+2),2)),RIGHT(LEFT(D10,FIND(" ",D10)+1),1))
Year:
=RIGHT(LEFT(D10,FIND(",",D10)-1),4)
Hour:
=IF(RIGHT(LEFT(D10,FIND(":",D10)+4),2)="am",RIGHT(LEFT(D10,FIND(":",D10)-1),2),RIGHT(LEFT(D10,FIND(":",D10)-1),2)+12)
Minute:
=RIGHT(LEFT(D10,FIND(":",D10)+2),2)
All this combined in the DATE and TIME function to give a single formula:
=DATE(RIGHT(LEFT(D10,FIND(",",D10)-1),4),VLOOKUP(LEFT(D10,FIND(" ",D10)-1),A1:B12,2,FALSE),IFERROR(VALUE(RIGHT(LEFT(D10,FIND(" ",D10)+2),2)),RIGHT(LEFT(D10,FIND(" ",D10)+1),1)))+TIME(IF(RIGHT(LEFT(D10,FIND(":",D10)+4),2)="am",RIGHT(LEFT(D10,FIND(":",D10)-1),2),RIGHT(LEFT(D10,FIND(":",D10)-1),2)+12),RIGHT(LEFT(D10,FIND(":",D10)+2),2),0)
Then change the format of the cell to:
mmmm dd yyyy hh:mm AM/PM "PDT"
This will give:
June 12 2017 09:07 AM PDT
To add a comma(,), use the custom format:
mmmm dd yyyy"," hh:mm AM/PM "PDT"

Difference between two dates in excel 2013

I want to calculate the time difference between two dates with the following criteria:
1) excluding sundays and public holidays
2) TIMING: Mon to Fri = 7 AM to 7 PM &
Sat = 7 AM to 3 PM
I tried a many formulas and nothing works for me.
please any ideas??
Eg: Start Time: 3/6/2015 10:00 AM
End Time: 4/6/2015 12:00 PM
Then I should get the difference as 13 hrs (excluding time out of business hours)
If start and end "timestamps" will always be within working hours then you can use a formula like this:
=(SUM(NETWORKDAYS.INTL(A2,B2,{1,"1111101"},H$2:H$10)*{12,8})-IF(WEEKDAY(B2)=7,8,12))/24+MOD(B2,1)-MOD(A2,1)
Assuming start date/time in A2, end date/time in B2 and holiday list in H2:H10
Format result cell as [h]:mm and if start time is today (Monday) at 14:00 and end time is exactly a week later you will get the result 68:00 (5*12 hour days and 1*8 hour Saturday)

Resources