Trying to import %m/%d into Rails where no %Y is available in the csv - csv

I have a csv with only the month and date, like this: 08/22, and can't import it into my Rails 4 app. It just gets ignored. I've tried:
:birthday =>DateTime.strptime("%m/%d").strftime("%m/%d")
converters: [:date]
and a few other things. Is is at all possible to bring a date that has no year into a Rails database?

if you are the one performing the imports / building the spread sheet, you could format the date field in the excel sheet to a random year, then upload the form with the dummy year but then use strftime in your index, show pages ect to only display the date and month. if year is not important i dont see why this wouldnt work.
I have used this method in the past where my client provided data did not have years attached and it worked for me.
hope this helps.

Related

How to import .Net DateTime and TimeSpan in Excel via Json and Power Query

Short version: How do you import data with .Net DateTime or TimeSpan types to Excel tables via Json and Power Query? I don't get it to work.
More details: I have sparse data (int values logged sparsely in time) that I want to import as tables and graphs in Excel. In my C# code it's represented as Dictionary<DateTime, int>. I export the data to a Json file (using System.Text.Json) and import it to Excel via a Power Query. In Power Query the DateTime ends up as a text column (looks like 0001-07-24T01:05:45 in the preview). I change the type to Date/Time and all seems well (looks like 0001-07-24 01:05:45 in the preview). But when I save and load it to a table, the column is blank. What's going on?
I tried the same thing with TimeSpan instead. Json couldn't serialize TimeSpan so I just used .ToString() before serializing it. In Power Query I converted the values to Duration and when I loaded it to tables it actually worked... although I couldn't get the sorting to work. I could only sort it A->Z, not by time, even though Excel obviously understood that they were times (the graph was sparse as expected).
Sorry if this seems like an Excel / Power Query question, but it's related to the two .Net types and I thought there must be many .Net programmers that have done this before.
If you have 0001-07-24T01:05:45 in powerquery, formatted as date/time it will show you
and load into excel as blank because there is no year 0001 in Excel. You need to set the year to be something else
This adds a new column where 0001 becomes 2022
= Table.AddColumn(#"PriorStepName", "Custom", each DateTime.FromText(Text.Replace(Text.From([ColumnNameHere]),"0001","2020")),type datetime)
or this, which replaces 0001 with 2020, in place
= Table.TransformColumns(#"PriorStepName",{{"ColumnNameHere", each DateTime.FromText(Text.Replace(Text.From(_),"0001","2020")),type datetime}})

Week of Year Microsoft Flow

I have a flow that grabs data from a SharePoint list every week, and then creates a CSV file from that list. Since it is run every week, I want to name the file FileName_Week_xx but I don't see a weekofYear epression or something similar when naming the file.
Is there a way to use the other time expressions or create a variable that determines what week of the year the data is being pulled?
I guess You can try an expression step with something like:
add(div(dayOfYear(utcNow()), 7),1)
Please refer to the below screen show of the flow steps You can create. Hope it helps :)

Importing CSV date column to SQL changes date

I'm experiencing an issue where when I import using SQL import, or ETL job, a CSV Excel type file into SQL that the dates are being converted or altered to something else.
I'm trying to ID a pattern but for example here are two date samples. before and after:
Before After
======= =======
30/01/2015 20/01/1930
11/09/2015 20/09/2011
Seems like the day number is being used to replace the year portion, and in first case century reverts to 19, and the original century portion is, in some cases, overwriting the day, if that makes sense?
I can't see why it would do this, none of the other files I had done this, and they were all Excel CSV files. They were transferred the same way to the same data mart from the same file location.
It's scary to think one file can suddenly do this with no error being raised, and just lucky it was spotted in the end reports.
Any thoughts greatly appreciated.
Thanks
Andrew
Depends on the SQL dialect you are using. For example, Mysql only accepts dates in YYYY-MM-DD format.
The Date format in excel is 06/09/2015.
To make sure everything is okay, just explicitly set the Date format in Excel.
In order to change the date format in excel: right click on the top cell. Choose format cells from the drop down list. change the local to something like 'Afrikans'. Choose the format that looks like 2001-03-14. Use the top cell to fill down. Then save the document.

CSV file using mixture of date formats

I've been producing a csv file from Salesforce Marketing Cloud. The date column is using two different date formats for seemingly random dates:
How can I stop it from doing this? I have also exported it from SFMC in a text format, and all the dates are in the same format in that file, but as soon as I convert it to CSV it puts them in this variety of formats. Can anyone help?
Excel tries to fix it for you. You should import into excel using the' Data Tab > Get External Data'. As you import make sure you select the correct date format for the column with your dates. ie MM/DD/YYYY h:mm:ss AM/PM.

How to clean/sort data in R with multiple entries corresponding to few of the intermittent row variables under several columns?

the data sample imageHow to clean/re-organize data in R/R Studio in case a row variable has more than one entries under the column variables ? e.g. I have a data-set that has 13 columns , and 14 rows, in each of the month tab of an excel workbook depicting a year, there are 5 workbooks like this. So, in total there are 5 * 12 = 60 tabs. In each of the month tab, before the second/third/ etc. row starts, the previous row already has multiple entries under a column head, like the one in the attached image at the beginning.
how to format/clean this whole data, including all the months in a year, and also accounting for 5 years on trot, and make this suitable for analysis ? Thanks in advance .
Are you looking to import the excel data into R studio?
Look at the library "xlsx" in order to read excel sheets in.
This will be entered into your environment as a data frame. Available for you to analyse. If you want to have R studio recognise dates, then look at the library "lubridate".
You aren't particularly clear as to what you want here, after you've done some R coding, put it up, and we can help further.