ExampleReturn a specified part of a date: SELECT DATENAME(year, '2017/08/25') AS DatePartString; Try it Yourself »Definition and UsageThe DATENAME() function returns a specified part of a date. This function returns the result as a string value. SyntaxParameter ValuesParameterDescriptionintervalRequired. The part to return. Can be one of the following values:
Technical DetailsWorks in:SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data WarehouseMore ExamplesExampleReturn a specified part of a date: SELECT DATENAME(yy, '2017/08/25') AS DatePartString; Try it Yourself »ExampleReturn a specified part of a date: SELECT DATENAME(month, '2017/08/25') AS DatePartString; ExampleReturn a specified part of a date: SELECT DATENAME(hour, '2017/08/25 08:36') AS DatePartString; Try it Yourself »ExampleReturn a specified part of a date: SELECT DATENAME(minute, '2017/08/25 08:36') AS DatePartString; Try it Yourself »If I understand correctly, your query returns one record for a specific key. However, this isn’t what I need. I don’t want to specify the key because the query should return all documents with all keys. Maybe I wasn’t clear enough, so I’ll share an example. Here is a document in my collection in mongodb 4.4.12(could not use latest 5.0.6 because of the Intel AVX support required by mongodb 5.0.0 and above I really want to use the native mongodb time series but for now i can’t Now back to the document, here it is
and these documents get inserted every 1 minute, sometimes a minute is skipped and 2 minute range before next insert, even though i run the cronjob every 1 minute, but many factors that does not allow every minute always
Please note i insert many documents all at once using same exact ISODate, so i can have like 100 documents all using same ISODate with different and unique values for Eventually i will move over to using the native timeseries MongoDB's New Time Series Collections What i want to do is be able to
|