Strange date behavior with mongoose - node.js

I have a document in my database that gets displayed like this when inspected with MongoDB Compass:
Now I have experimented a bit with it on the command line:
I understand that getMonth returns one because they range from 0 to 11, but why does getDay return numbers that to me appear have no relation whatsoever with the saved date?

getDay() returns the day of the week (from 0-6).
So wednesday will be 2.
Try getDate() to return the day of the month.

if you look documentation for getDay() you will find out that:
The getDay() method returns the day of the week (from 0 to 6) for the
specified date.
I think that on your computer culture week starts on Sunday. So you are getting numbers that you are gettings.
Also I bolive that you wanted to use getDate() method:
The getDate() method returns the day of the month (from 1 to 31) for
the specified date.

Related

SharePoint Formula: [Created]+60 days = Extension Date (but need it to be a weekday)

I need help with a formula that will add [Extension], a choice field of 30, 45, or 60, to [Created], and return a date [Extension Weekday].
BUT, that future date must be a weekday.
Example: [Created] + [Extension] = [Extension Weekday], but if the result is a Saturday or Sunday, calculate it as the next Monday.
Thanks!
You can use following formula:
=A2+B2+((WEEKDAY(A2+B2,2)=6)*2)+((WEEKDAY(A2+B2,2)=7)*1)
First weekday = 1 = Monday, last = 7 = Sunday. Change WEEKDAY function second parameter if needed.
You might use following functions:
TEXT() : =TEXT(20/02/2020;"dddd") shows the name of that day.
IF(condition;result)
OR(condition1;condition2)
So you'll need something like:
=IF(OR(TEXT(<date>;"dddd")="Saturday";TEXT(<date>;"dddd")="Sunday");"Monday";TEXT(<date>;"dddd"))
The formatting, day naming, ... might be language dependent, so I'll advise you to do some experimenting, but this gives you a start.

Need to change date into current work week (1-52), but skip to the next week if the day is Wed - Sat in VBA

I'm having trouble writing code in VBA that would allow me to input any given date then have an output of the current work week. I need a restriction of if the date is Sunday through Tuesday, it will keep that current work week and year but if the date is Wednesday through Saturday, then the next work week and year will show. For example, I'm looking to input (5/28/19) and have an output of 201922 or an input of (5/29/19) with an output of 201923 even though its technically the same work week.
Before getting too in depth, I do have a working function that provides the year and work week, but I'm trying to adapt the function or add a separate function that will change in to the next work week according to the given date.
I'm new to VBA but have tried to do a little research over the last few days. I was thinking that I could somehow have one input of the date then have two outputs where one would be the year and work week then the other would be the number associated with that date (1 for Sunday, 2 for Monday, and so on). I tried to create an if then statement that says if the number associated with that date is 1, 2, or 3 then the workweek would stay the same. If it was any other number then 1 would be added to that work week so it would move to the next one. I'm having trouble with trying to make two outputs and have them connected, if that makes any sense.
This is the code that I tried to create, but continuously failed at making. The function that gives the correct work week (without the adaptation of the work week based on the date weekday) is WWV1
Function WWV2(WeekdayName As Integer)
Dim WWV1 As Integer
If WeekdayName(Date) = 1 Or 2 Or 3 Then WWV1 = WWV1
Else: WWV1 = WWV1 + 1
End Function
This provides the cell with #NUM! when I use the function in that cell, which I assume is because I need to somehow connect the two functions.
how about this:
=YEAR(A1) & TEXT(WEEKNUM(A1,13),"00")
WeekNum returns the weeknumber with 13 saying it starts on Wednesday:
VBA
wkcd = Year(Range("A1")) & Format(Application.WeekNum(Range("A1")),"00")

vba: get the week day number from a date?

I would like to get the week day number from a date.
E.g. : if it is a Monday returns 1, if it is a Tuesday it returns 2, ... if it is a Sunday it returns 7.
I was wondering if there is a direct function to obtain this, for instance:
DayNumber = Format(Date, <format unknown to me>)
The closest I could get is to use the function:
DayNumber = Format(Date, "dddd")
then loop through a predefined list of possible names, but I still wonder if there is a simpler way?
A bit of googling would have found the WEEKDAY function
weekday(date,vbMonday)

Excel2016 - Excelformula - Return a date which is not referenced as a Saturday & Sunday

I am looking to return the date (deadline) into a cell sheet which is not on a Sat and/or Sun. So for example, if the starting date is Monday 04/09/2017 and we need 6 days to complete the work, I want the deadline to says Monday 11/09/2017.
The response from User91504 will solve your issue, I will just add to use something like this in your case
=WORKDAY(J13,6)-1
As the formula is taking the current day into account as part of the leadtime, otherwise it will provide 12/09/2017 as result
=WORKDAY(your start date , number of days to add)
If your date was in Cell J13, then:
=WORKDAY(J13,6)
Or if you manually type the date, use DATE function:
=WORKDAY(DATE(2017,9,4),6)

Excel weird timestamp. How to convert it back to normal timestamp?

I'm using Flash and as3 to convert Excel timestamp to normal timestamp, thus - to normal date.
I have this function
public static function dateFromExcel(date:Number):Date {
return new Date(1970, 0, 1 + (date - 25569));
}
This works fine if I need only a correct date (year, month, date). But now I have a time, that is displayed in Excel as follows:
1:00:00
But the real value of the cell is:
1/1/1900 1:00:00 AM
That's a autoformatted by Excel. Now, when I read Excell with as3 code, as with dates, I get decimal number. For this time I get this:
1.0416666666666667
When I run the same function on this decimal number, I get this:
Mon Jan 1 00:00:00 GMT+0200 1900
Which is obviously incorrect.
As I get, with that function I can only work with the date and not the time. Can anyone look at this and figure out, how to get the time to work with this function too?
While I was writting this question, I figured it out myself.
It is documented, that excel timestamp is the total days starting from 1900/01/01.
So this means, that the numbers after the decimal point is the percentage of the one day. For me, I just multiplied that number with the total count of seconds in one day and got the correct time. The function is as follows:
public static function dateFromExcel(date:Number):Date {
var sec_ind_day:Number = 86400;
var secs:Number = sec_ind_day*date%1;
var _d:Date = new Date(1970, 0, 1 + (date - 25569));
return new Date(_d.fullYear, _d.month, _d.date, _d.hours, _d.minutes, secs);
}
So, anyone who got the same issue, this should work fine.

Resources