Hugo Date vs PublishDate - hugo

Hugo offers a few date page variables:
Date - the date associated with the page
PublishDate - the date on which the content was or will be published
LastMod - the date the content was last modified
ExpiryDate - the date on which the content is scheduled to expire
LastMod and ExpiryDate make sense to me, but I am puzzled as to the difference between Date and PublishDate.
What are some examples of when Date and PublishDate are different?

If...
you are using the default meaning of date and publishDate (see below),
both are defined for a page,
and date is different from publishDate
Then...
publishDate is used to determine if a page is in the future (i.e. if hugo's -F or --buildFuture flag is required for the page to be built)
date is used to order pages in the default ordering (Weight > Date > LinkTitle > Title > FilePath).[*] The default order is used in next/previous navigation and can be used in a range.
Configuring dates is discussed in https://gohugo.io/getting-started/configuration/#configure-front-matter. Here is the default for date and publishDate:
frontmatter:
date:
- date
- publishDate
- lastmod
publishDate:
- publishDate
- date
Because I want date and publishDate to mean the same thing, I have the following in my config.yaml:
frontmatter:
date:
- publishDate
- :filename
- date
- :fileModTime
publishDate:
- publishDate
- :filename
- date
- :fileModTime
I've made them the same because I, too, was puzzled by their difference!
[*] Info about ordering content in Hugo is at https://gohugo.io/templates/lists/#order-content

Related

How to get a weekly view from date field in snowflake

I have a small query mentioned below.
Need to break down a date field "DAY" to monthly and weekly wise in snowflake.
Input:
DAY
-------
2022-06-09
2022-04-04
Output
DAY_MONTH
----------
2022-06-01
2022-04-01 Monthly wise--- Its done
Here I have used
DATE_FROM_PARTS( YEAR(DAY), MONTH(DAY), 1) AS DAY_MONTH
DAY_WEEK
----------
2022-06-06
2022-04-04
They should be first day of working days like (Monday). How to do that for a weekly view?
I think you're looking for the date_trunc function:
set ts = '2022-07-07 11:14:00'::timestamp;
select date_trunc('DAY', $TS);
select date_trunc('WEEK', $TS);
select date_trunc('MONTH', $TS);
This is showing for a timestamp to show how it truncates to the day, but it works the same way for date types. Truncating to the week will start by the week_start parameter that's in effect (it will default to Monday as the start for this function):
https://docs.snowflake.com/en/sql-reference/parameters.html

How to get From Date and To Date for the current year based Old From Date and Duration(in months)

E.g. I have a table(Table1) that has From Date, To Date and Duration columns.
From Date: 5/1/2019
To Date: Null
Duration: 12 Months
Now I want to calculate the From and To date based on the Date from another table(Table2).
If Table2 Date is '7/1/2020' Then From Date should be 5/1/2020 and To Date should be '4/30/2021' as '7/1/2020' is after the From Date(5/1/2019 + 12-month duration) of Table1
If Table2 Date is '7/1/2021' Then From Date should be 5/1/2021 and To Date should be '4/30/2022' as '7/1/2021' is after the From Date(5/1/2020 + 12-month duration) of Table1
and so on...
So how can I achieve this in SQL Server.
Seems like you just want to use a bit of DATEFROMPARTS:
SELECT DATEFROMPARTS(YEAR(#YourDate),5,1) AS FromDate,
DATEFROMPARTS(YEAR(#YourDate)+1,4,30) AS ToDate;
Though this doesn't address this requirement, but it doesn't make much sense:
From Date: 5/1/2019 To Date: Null Duration: 12 Months
Any date to NULL doesn't have a "duration" of 12 months, it has an unknown duration, as NULL is an unknown value. I've thus assumed you want the same logic for the other 2 examples, and have an actual 12 month gap.

SSRS Parameter Not Dynamically Updating - Last Day of Month

Report has two parameters
DateFrom
DateTo
DateTo set to "Always Refresh"
I have the following expression for DateTo - Default Values - so that it will dynamically default to the last of the month set by DateFrom
=DateSerial(Year(Parameters!DateFrom.Value), Month(Parameters!DateFrom.Value), "1").AddMonths(1).AddSeconds(-1)
However, the field doesn't update.
It shows the correct last date of month when DateFrom is selected the first time.
If DateFrom is set to 15/02/2019 then DateTo will show "28/02/2019 23:59:59".
But if you subsequently change DateFrom to a different month, DateTo doesn't update - still shows "28/02/2019 23:59:59".
I have just added these Parameter properties
1) data type -> date/time and allow nulls
2) available values -> specify values -> label and value as
=DateSerial(Year(Parameters!Datefrom.Value), Month(Parameters!Datefrom.Value), "1").AddMonths(1).AddSeconds(-1)
3) Advanced=always refresh. and checked notify me box.
This works the moment i change param 1 ('Datefrom') i get new dateto as last date from month.
Are your settings matching this?

T-SQL for deletions based on tiered datetime

I have a table that essentially stores revisions of certain datasets (i.e. edits back through time if you like). The date of the revision is unimaginatively stored as a datetime field named revision.
Each new revision is taken daily, at midnight.
If this table were left to populate, there would be a set of rows for every single day, where each set of rows shares the same revision datetime field, e.g. 2010-10-31 00:00:00.
I would like to implement a stored procedure as a job that essentially runs daily and cleans up the number of revisions in this table, based on criteria similar to the way the Time Machine features works in OS X. Namely, the revisions to be kept should be:
one revision each day in the past week (since weekly revision below)
one revision each week for every week after this (the midnight Monday morning revision)
one revision each month for revisions beyond a year old (the midnight revision of the first day of the month)
So, for example, right now I would expect to see the following revisions:
2010-10-30 (daily)
2010-10-29 (daily)
2010-10-28 (daily)
2010-10-27 (daily)
2010-10-26 (daily)
2010-10-25 (daily/weekly)
2010-10-18 (weekly)
2010-10-11 (weekly)
2010-10-04 (weekly)
2010-09-27 (weekly)
...
That is of course bearing in mind my data set isn't yet a year old.
So, what's the best and most concise DELETE FROM to achieve this? Thanks!
Taking each case
Last weeek: simply filter < DATEADD(day, -8, GETDATE()) because no processing is needed. ( allows for time component and assumes clean up runs after midnight)
Between week ago and year ago: Use DATEPART(weekday, revision) <> 2. Depends on ##datefirst.
More than a year ago: Use DATEPART(day, revision) <> 1
So, something like but untested...
DELETE
MyTable
WHERE
Revision < DATEADD(day, -8, GETDATE())
AND
(
Revision > DATEADD(year, -1, GETDATE()) AND DATEPART(weekday, revision) <> 2
OR --Must be > 1 year ago)
Revision < DATEPART(month, revision) <> 1)
)

SQL date related

Hi all i want to take record from table named Tblbatch where batch starting date should be from augest 2007 to july 2010...
I want to fetch such records which came in between this two dates
Select * from Tblbatch where startDate between '01-08-2007' and '31-07-2010'
provided you have a datetime column "startDate"
Note : that using between includes both the dates specified.
If you want to avoid the dates either change the boundary dates to + - 1 respectively or use > and < conditions

Resources