Get Weekday number based on YYYYMMDD ?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to output day number based on date in format YYYYMMDD but unsure how

E.g Monday = 1 to Sunday = 7

20202905 = 5

20202505 = 1

I think I need to convert to a true date first but maybe another way


Thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Another way ....
Book1
AB
1202029055
2202025051
Sheet9
Cell Formulas
RangeFormula
B1:B2B1=WEEKDAY(DATE(LEFT(A1,4),MID(A1,7,2),MID(A1,5,2)),2)
 
Upvote 0
Thanks @JoeMo

Will it achieve the same result regardless of excel version/language or Windows language.

As my data is always YYYYMMDD

But some users have their date in 29/05/2020 and others in 05/29/2020
 
Upvote 0
Thanks @JoeMo

Will it achieve the same result regardless of excel version/language or Windows language.

As my data is always YYYYMMDD

But some users have their date in 29/05/2020 and others in 05/29/2020
You are welcome. Despite the title of your post, the data you used in your example are in YYYYDDMM - not YYYYMMDD - format. The solution I posted will work with the YYYYDDMM format in the USA region., and I believe in any Excel version. I don't know about other regions.
 
Upvote 0
The input information that you provided and result that you need not clear.
Consider the following.

T202005c.xlsm
ABCD
1129-May-20202005295B11 date custom formatted yyymmdd
12
132020052929-May-205A13 text information
14
3a
Cell Formulas
RangeFormula
B11B11=A11
C11,C13C11=WEEKDAY(B11,2)
B13B13=DATE(LEFT(A13,4),MID(A13,5,2),RIGHT(A13,2))
 
Upvote 0
@JoeMo @Dave Patton

sorry for the confusion, it is YYYYMMDD as title

how would i output column C values with VBA ?

OTqjn27.png
 
Upvote 0
What information is in Column A? Is the data Text or Dates custom formatted.
Use the formula cited for the type of input that you have.
You can custom format the date column to show the Day like Monday.
 
Upvote 0
with Power Query

dates.png

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TText = Table.TransformColumnTypes(Source,{{"Raw", type text}}),
    Date = Table.AddColumn(TText, "Date", each Text.End([Raw], 2)&"/"&Text.Middle([Raw], 4, 2)&"/"&Text.Start([Raw] ,4)),
    TypeLocale = Table.TransformColumnTypes(Date, {{"Date", type date}}, "en-GB"),
    DOW = Table.AddColumn(TypeLocale, "Day of Week", each Date.DayOfWeek([Date])+1, Int64.Type),
    TSC = Table.SelectColumns(DOW,{"Date", "Day of Week"}),
    DayName = Table.AddColumn(TSC, "Day Name", each Date.DayOfWeekName([Date]), type text)
in
    DayName
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,872
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top