Localized format without the day - dayjs

Is there any way to get a localized format in DayJS plugin but without the day? I need to show in a calendar the month and year only but depending on the locale, the month can be on the first place or at the end.
I've checked in the docs (https://day.js.org/docs/en/display/format#localized-formats) but it seems there is nothing with year and month only.
dayjs().format("LL") // December 7, 2022
// what I would like to get: December 2022 or 2022 December (depending on the locale)
Thanks in advance

Related

How to separate month and year in Date in pug

This is the format of date saved in MongoDB:
Sun Feb 13 2022 05:30:00 GMT+0530 (India Standard Time)
How to separate month, year and day from this date in pug? I want to take this date in pug and display month and year separately.
Pug is built on JavaScript, so you could just use string manipulation to parse the month, day, and year—assuming the format is consistent.
-
// variable containing date string
const myString = "Sun Feb 13 2022 05:30:00 GMT+0530 (India Standard Time)"
// break into individual variables using destructuring
let [dayOfWeek, month, day, year, time, timeZone, timeZoneName] = myString.split(' ')
p.postDate Posted on #{month} #{day}, #{year}
Thanks everyone for your help, i found a npm library called moment.js. It is super easy to use and also has many built in functions.

Excel - count a specific value based on a part of another cell

I thought this would be a no brainer. But I really need help to solve it.
I have a row of dates: 10 july 2020, 11 july 2020 and so on (Swedish excel).
Below each date are strings for example "FP". I wish to achieve a counter for each "FP" that is below a specific month of a year, such as july 2020.
The way I approached this was with
=COUNTIFS(G1:UG1;"*july 2020";G2:UG2;"FP")
However the * doesn't do what I want it to. Is there another way to do this?
Please help! :)
The dates are true dates and as such the july 2020 is just a format of a number and not actually there.
Instead BookEnd the date:
=COUNTIFS(G1:UG1;">="&DATE(2020;7;1);G1:UG1;"<"&DATE(2020;8;1);G2:UG2;"FP")

How to remove ordinals from datetime strings in google docs or excel?

I have a list of datetimes that happen to have the ordinal in them (1st, 2nd, 3rd). This causes problems for working with dates and converting to unix time.
How to remove the 'rd' or 'th' suffixes from dates?
example dates:
April 23rd
Apr 24th
Apr 30th
May 1st
May 7th
May 8th
May 15th
May 21st
May 22nd
May 28th
Jun 18th
Jun 19th
Jun 26th
Try this:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"st",""),"nd",""),"rd",""),"th","")
and, to convert it to a "real" date with today's year:
=--SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"st",""),"nd",""),"rd",""),"th","")
or, shorter (and works in Excel, not sure about Google):
=LOOKUP(1E+307,--SUBSTITUTE(A1,{"st","nd","rd","th"},""))
Be sure to format it as a Date
If the dates were just text and always had the last two letters, then it would just be
=LEFT(A1,LEN(A1)-2)
If you wanted to check that the letters were there first, you could use something like
=IF(OR(RIGHT(A1,2)={"st","nd","rd","th"}),LEFT(A1,LEN(A1)-2),A1)
Has to be entered as an array formula in Google Sheets
=ArrayFormula(=IF(OR(RIGHT(A1,2)={"st","nd","rd","th"}),LEFT(A1,LEN(A1)-2),A1))

YEAR() fitting to WEEKNUM(...,21) in Excel

I'm looking for a way to specify return 2015 for a date within this week, but in Calendar Year 2014.
This current week according to the Thursday system is Week 01/2015. But the Year function will still return 2014.
Something like:
IF(AND(WEEKNUM(TODAY(),21)=52,WEEKNUM(TODAY()+7,21)<>53),YEAR(TODAY())+1,YEAR(TODAY())
but a little bit more reliable and elegant.
Anybody got something?
Happy Happy
Ben-san
The "Year" of the week is determined by the year of the Thursday of that week (assuming ISO week numbers) so you can just find the Thursday and then get the year of that date, i.e. for any date in A1
=YEAR(A1-WEEKDAY(A1,3)+3)
or, similarly, for today's date
=YEAR(TODAY()-WEEKDAY(TODAY(),3)+3)
This works for any date in any year.......and might put days in Jan in the previous year also, e.g. 3rd Jan 2016 is in the last week of 2015

Microsoft Excel - Date Sequence

I had a look for this question before I asked, but sorry if it's a repeat.
In a spreadsheet, I want to employ a date sequence.
eg. Stock Arrives - Friday 22nd February 2013
then, on the 22nd of Feb, that date CHANGES to the next 7 days.
eg. Stock Arrives - 1st March 2013
and then repeats this indefinitely.
Is there any way to do this?
If you want to always show the next Friday you can use this formula
=TODAY()+8-WEEKDAY(TODAY()+2)
That will show Friday 15th Feb 2013 right now.....but on 15th feb it will change to showing 22nd Feb
For other days just change the +2 at the end, e.g. +3 will give you next Thursday, +4 will give you next Wednesday, +5 will give you next Tuesday etc.
This is some way you could do this though I am not sure if this is what you want.
=B1+FLOOR((TODAY()-B1)/7,1)*7
Basically, have a cell hold the start date of the stock inventory (first date in the past where you received this stock). You need to have also the number of days between restocking (here I hardcoded 7). Then you can just use the floor of the difference between today and that date divised by the restocking time. This will give you a step-function-style behaviour.

Resources