Optional date and month in date field in Laravel - laravel

I have a Photo model that contains information about a historical photo, including date of photography. Often we do not know exactly which day the photo has been taken, but only the month or year. Is there some way to solve this without having three database fields for date, month and year.

date("m-Y",strtotime($date));
I think this could work. Let me know if it helped.
You can enter a date with a random day. It will cut it out.

Related

Add one day to custom date in freemarker

I need to add one extra day to the specific day ,kindly help me
let say I want to add one day to this date "31/12/2020"
enter image description here

Can I generate the number of business days in a month in Visual Studio?

I have a report that takes sales data from a few tables. I want to add a field that will divide the total sales for the given month by the total number of business days in that same month. Is there a way I can calculate that in an expression? Do I need to create a new table in the database specifically for months and their number of business days? How should I go about this?
Thank you
Intuitively, I would say that you need a simple function and a table.
The table is to host the exceptions like Independence day, labor day, etc.
The function will get two parameters: Month and Year (I'm not providing any sample code since you haven't specified which language you are using).
It will then build a date as yyyy-mm-01 (meaning, first day of the month). If will then loop from 2 to 31 and:
Create a new date by adding the index of the loop to the initial date,
Check if the resulting date is still within the month,
Check if it is a working or not working day (e.g. Sunday),
Check if it is found within the table of exceptions.
If the created date passes all the above tests, you add 1 to the counter.
Though it might look complex, it is not and it will provide you the correct answer regardless of the month (e.g. Feb.) and the year (leap or not).

DAX - Sum Workdays By Month within Range

I've been at this one a while.
Objective: Pivot a monthly summary of days worked by Resource within the range for that Resource line where those dates (from StartDate to EndDate) correspond to the Dates table IsWorkday field.
Thanks for your help!
It depends on how you define what a workday is. I suspect this is Monday thru Friday? If so, try the weekday function.
=WEEKDAY(serial_number,2)
Where serial_number is the cell with a date you want to identify. This would not exclude holidays, I would recommend an index/match on some holiday reference table for that.
https://support.office.com/en-us/article/WEEKDAY-function-60e44483-2ed1-439f-8bd0-e404c190949a

RethinkDB: Can I group by day / week / month?

My table has a timestamp field, which is a standard RethinkDB date field.
Can I group rows by day / week / month using this timestamp field? Couldn't find any examples in the group() docs.
To group by month, day, or day of week individually:
r.table(...).group(r.row('timestamp').month())
r.table(...).group(r.row('timestamp').day())
r.table(...).group(r.row('timestamp').dayOfWeek())
Grouping by the week isn't as easy at the moment, because ReQL is currently missing a function to get the week number from a data (see https://github.com/rethinkdb/rethinkdb/issues/2055 ). You can probably work around that by using some custom JavaScript code through r.js(). Please let me know if this is important for you, so I can look into it.
If you want to group by combinations of multiple things, e.g. day and month:
r.table(...).group([r.row('timestamp').month(), r.row('timestamp').day()])

Oracle SQL Output to Excel - Date format issue

I ran an SQL Query for Oracle which consists of Invoice date and Check date. When these data are copied on to an Excel Spreadsheet as text, it's dispayed as ex: "13-10-31" (Oct 31, 2013). However, when converted to date format, it's displayed as "10/13/1931". I've tried different date types but it always recognizes as the first part of the text as the day, then month, then year. I need these values to be setup as a date format as I need to calculate Days Payable Outstanding and other related ratios.
Is there any way to convert these values so that Excel recognizes the day, month, and year correctly? Would there be a macro that could automate this process for existing data and data that will be added in the future?
Thank you in advance.
Firstly, I hope the data type of your date column is DATE.
Secondly, the date should always have year as YYYY and not just YY. The world has already learned from Y2K bug.
If above two points are met, then while displaying use to_char(date_column, 'mm/dd/yyyy'). Thus, with YYYY format, there won't be any confusion between year and other fields.

Resources