I am trying to create a spreadsheet with all the dates of Sunday in one column. How can I go about doing this? I have tried by using DAYVALUE(1), but cant get that to return a date.
First, e.g. in Calendar, lookup the date of the first Sunday in January for the year you want to create the spreadsheet of Sundays in a year. For this example, lets use the first Sunday in January of 2017, i.e. January 1, 2017.
In Numbers, e.g.:
Set A1 to: Date
Set A2 to: January 1, 2017
Set A3 to: =A2+7
Drag A3 down to: A54
Related
I am new to snowflake and my manager wants me to retrieve the data of the past month when it is 5th of the current month. For example if today is 5th April, then ask snowflake to retrieve the data of the past month i.e. from 1st March 2021 to 31st March 2021 and similar for all the other months.
The reason why he wants to update the last month data on 5th of every next month because that is the day when we get the data.
I tried to use the DATEADD function but it is more complicated than just using this function.
Thanks in advance!
PS: The data for every month has same date. for example: the date is like - April 20th will be stored in the database as "2021-4-01" - and same for April 25th date will be stored as "2021-4-01" .
The day doesn't change in the database, just the month and year.
as to the prior month window that can be done via DATE_TRUNC and DATEADD
select
current_date as cd
,date_trunc('month', cd) as end_range
,dateadd('month', -1, end_range) as start_range
;
gives:
CD END_RANGE START_RANGE
2021-04-21 2021-04-01 2021-03-01
the other half of the question only do it on the 5th, if you have a task run daily etc. can be solved via
,day(current_date) = 5 as is_the_fifth
or if in an inline way
iff(day(current_date) = 5, <do true stuff>, <do false stuff>)
I have an sheet with the Table, having Column A in Calendar Week. I would like to generate an chart with x axis as month with the data available in the table.
Could anyone help me to code it ? I am struck how I can convert an weeknumber in the column to month.
Could anyone suggest, how I can generate a chart for these data with month in my x/axis. I am not getting an clue to do this. Any lead would be helpful.
This is a formula to convert the week number in cell A1 into month
=MONTH(DATE(2017,1,-2)-WEEKDAY(DATE(2017,1,3))+A1*7)
Note that you also need to know the year the week number refers to, because it can differ from year to year. In this example it is fixed to 2017.
Note that week number != week number.
There are different methods how week numbers are calculated.
This formula example is based on ISO week numbers, with a week starting on Monday and the week containing the 1st Thursday of the year is considered week 1. For example, in the year 2016, the first Thursday is January 7, and that is why week 1 begins on 4-Jan-2016.
Here is some info about week number calculation based on different week numbers: Week Numbers In Excel
You need to use the formula
=TEXT((((A1-1)*7)+DATE(2017,1,1)),"m")
This will turn the week number into a date, then extract the month number
I am looking to save an individual worksheet from a workbook with today's date in the filename. ex. (c:\HotDogS\sales\Daily_12_04_16.xslx)
The problem I am encountering is getting the date to show right in the filename.
I have 1 cell that has the simple formula of =TODAY(). The cell is formatted for mm/dd/yy.
The formula I am trying to use to save the date for the sheet is:
=left(B3,2)&"_"&mid(B3,4,2)&"_"&right(B3,2)
So I am expecting a date of 12/04/16 to come out as 12_04_16, but I am getting is, 42_08_08.
Can somebody shed some light on this??
Thank you!!
Assuming TODAY is 4 December 2016, i.e. serial day number 42708, your formula is:
=left(B3,2)&"_"&mid(B3,4,2)&"_"&right(B3,2)
Left(B3,2) is 42. Mid(B3,4,2) is 08. Right(B3,2) is 08.
So your final result is 42_08_08.
You probably want to use (as an Excel formula):
=TEXT(B3,"mm\_dd\_yy")
Or in VBA you could use
Format(Range("B3").Value, "mm_dd_yy")
Excel stores dates as the number of days (and fractions of a day) since 0 January 1900. Therefore
1 January 1900 is day 1
31 January 1900 is day 31
1 February 1900 is day 32
29 February 1900 (even though it doesn't exist - but the bug has been maintained for backward compatibility) is day 60
1 January 1901 is day 367
4 December 2016 is day 42708
NOW() is day 42709.328 (it's about 7:52am on 5 December 2016 at the moment)
Referencing a cell formatted as date returns the underlying date serial number.
To get a date formatted as you want use
=TEXT(B3,"dd\_mm\_yy")
I have two columns called
1ST column Calendar Date:
16/02/2015
2nd Column Previous Day:
Yes
Formula I am currently using:
if([calendar Date])=today-1,"YES","NO").
The 2nd column returns value based on the 1st column.
However , the problem I am getting is when I run the data on monday when we have calendar date (day on friday). So it is showing "NO" as formula only returns data for previous day.
So I want something like this
Only when I run on Monday it should give me if([calendar Date])=today-3,"YES","NO").And all other workdays if([calendar Date])=today-1,"YES","NO")
Can you please help me on this.
If you cell A2 has the calender date then try with below formula.
=IF(WEEKDAY(A2)=6,(IF(A2=TODAY()-3,"YES","NO")),(IF(A2=TODAY()-1,"YES","NO")))
=IF(WEEKDAY(TODAY())=2,IF(TODAY()-3 = A12, "YES", "NO"), IF(TODAY()-1 = A12, "YES", "NO"))
first, identify whether the date today is monday or the other day of the week.
IF(WEEKDAY(TODAY())=2
If today is monday, then you can create the condition that the previous day must be friday [today()-3].
IF(TODAY()-3 = A12, "YES", "NO")
If today is not monday, then create the condition that the previous day is the date yesterday [today()-1].
IF(TODAY()-1 = A12, "YES", "NO")
To disregard weekends and holidays, you will want either the NETWORKDAYS or
NETWORKDAYS.INTL¹ function. Not only can you skip a conventional Sat/Sun weekend but you can add a reference to a list of holidays to be discounted as well. The newer NETWORKDAYS.INTL has a large selection of built-in non-standard 'weekend' formats or you can write your own. e.g. "0000011" is a standard Sat/Sun weekend and "0101000" is a Tue and Thu 'weekend'.
Both NETWORKDAYS and NETWORKDAYS.INTL count the number of days inclusively so you are looking for a value of 2, not 1.
For the following example, I've reset the computer's system date to Tue 19-Jan-2016 (the day after Martin Luther King Day, 2016).
=IF(NETWORKDAYS.INTL([#[calendar Date]], TODAY(), "0000011", Z$2:Z$11)=2, "Yes", "No")
If you wanted to get a little more elaborate, just use the NETWORKDAYS.INTL function with a custom number format of [=2]\Y\e\s;\No;\No. This allows you to retain the actual underlying value of the NETWORKDAYS.INTL formula while displaying Yes or No.
The results from the image above clearly show that both the weekend and holiday were discarded from consideration and that Fri 15-Jan-2016 is considered the previous day.
¹ The NETWORKDAYS.INTL function was introduced with Excel 2013. It is not available in earlier versions.
I'm looking for a way to convert an ISO date to Month and I also need to covert an ISO week to Month.
I need to do this in Excel and Access.
I found this formula for excel but when converting it to Access it does not work. Is there a simple way to accomplish this?
I found this Excel formula to convert ISO date to month (C2=date) and it works perfect:
=MONTH(DATE(YEAR(C2),MONTH(C2)+(WEEKDAY(C2,2)+(DAY(DATE(YEAR(C2),MONTH(C2)+1,0)))-(DAY(C2))<4),(((7-(WEEKDAY(C2,2)))+(DAY(C2)))>3)))
But when I modify it for an Access query it does not return the correct values:
Date_to_Month:MONTH(DATESERIAL(YEAR([WW_Index].[ISO_date]),MONTH([WW_Index].[ISO_date])+(WEEKDAY([WW_Index].[ISO_date],2)+(DAY(DATESERIAL(YEAR([WW_Index].[ISO_date]),MONTH([WW_Index].[ISO_date])+1,0)))-(DAY([WW_Index].[ISO_date]))<4),(((7-(WEEKDAY([WW_Index].[ISO_date],2)))+(DAY([WW_Index].[ISO_date])))>3)))
I also need to convert ISO week_year to Month. I found this formula but it does not work:
=MONTH(DATE(YEAR(C2),1,-2)-WEEKDAY(DATE(YEAR(C2),1,3))+D2*7)
Example: week 18, 2012 is the ISO week of Apr 30 through May 6, 2012. There is less that 4 April days in this week thus week 18, 2012 is in May.
Any help would be greatly appreciated.
I don't know access but you can do the first part (date to month) much more easily in excel with this formula
=MONTH(C2-WEEKDAY(C2-1)+4)
That should be easier to convert for access......
For the second part you are finding the Monday of the relevant week, hence you get the wrong month in some cases, the Thursday of the week (midpoint) should always be within the correct month so you can just add 3 to get that (-2 becomes 1), i.e.
=MONTH(DATE(YEAR(C2),1,1)-WEEKDAY(DATE(YEAR(C2),1,3))+D2*7)
I assume C2 is a date within the relevant year and D2 is the ISO week number
but probably better to have C2 containing the year, e.g. just 2013 and then you can use
=MONTH(DATE(C2,1,1)-WEEKDAY(DATE(C2,1,3))+D2*7)