How can I import both the Task Start date and the Task Finish date from Excel at the same time, using VBA? - ms-project

When I try to import both the Task Start date and the Task Finish date using the below code, the dates for the first task appear to import okay, but subsequent tasks' date values are changed from what they should be. If I comment out the line, MapEdit Name:="Map ", DataCategory:=0, FieldName:="Finish", ExternalFieldName:="Task_Finish_Date", to only import the Start date, then the correct dates are imported for the Start dates for all tasks (the dates are not changed) but, of course, I don't get my Finish dates. How can I import both the Start and the Finish dates for all my tasks?
MapEdit Name:="Map ", Create:=True, OverwriteExisting:=True, DataCategory:=0, CategoryEnabled:=True, _
TableName:=ws.Name, FieldName:="Name", ExternalFieldName:="Task_Name", ExportFilter:="All Tasks", ImportMethod:=0, _
HeaderRow:=True, AssignmentData:=False, TextDelimiter:=Chr$(9), TextFileOrigin:=0, UseHtmlTemplate:=False, IncludeImage:=False
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Outline Level", ExternalFieldName:="Task_Outline_Level"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Created", ExternalFieldName:="Task_Created_Date"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Start", ExternalFieldName:="Task_Start_Date"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Finish", ExternalFieldName:="Task_Finish_Date"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="% Complete", ExternalFieldName:="Task_Percent_Complete"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Notes", ExternalFieldName:="Task_Notes"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Board Status", ExternalFieldName:="Task_Board_Status"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Resource Names", ExternalFieldName:="Project_Resources"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Task Tags", ExternalFieldName:="Task_Tags"
MapEdit Name:="Map ", DataCategory:=0, FieldName:="Task Mode", ExternalFieldName:="Task_Mode"
FileOpenEx Name:=xlFile2, ReadOnly:=False, Merge:=0, FormatID:="MSProject.ACE.14", map:="Map ", DoNotLoadFromEnterprise:=True

It looks like I was able to fix my problem with importing Task Start and Finish dates.
As I think Rachel Hettinger suspected, the problem was not with my VBA -- it was with the data that was passing from Excel to MS Project. I was using Power Query to pull the data into Excel from its source. Power Query “fills in” empty date type values with nulls. I was passing the data from Power Query to Excel as such date type values. This brought in null dates instead of empty dates. When I then imported the supposedly empty, but actually null, date values from Excel into MS Project, Project added new, and changed existing, dates throughout my tasks.
Now what I do, instead, is I change my date values in Power Query from date type values to text type values. Also in Power Query, I then convert each null date entry to “”. That way, when I pass the data from Power Query to Excel, the dates are passed as text type values and the empty dates are brought into Excel as actual empty dates. (I do format the date columns in Excel as dates though.) And, when I subsequently import those empty values from Excel into MS Project, project handles them correctly.

Related

Avoid importing empty line breaks as \n

Some of the fields of an csv file I'd like to import contain text followed by an empty line break or two. As a result, when using read.csv2 to import thecsv file I obtain fields containing "[text] + \n".
I tried removing '\n' using gsub("[\n]", "", x) but this takes an awful lot of time. I was wondering whether I can simply avoid importing empty line breaks - then there will be no '\n' in my data. Using strip.white=TRUE does not work.
Any idea whether I can avoid importing empty line breaks?
The data saved in csv format, when opened with notepad, looks a bit like:
1;"text - text";1;Good
1;"text - text
";1;Good
2;"text - text";1;Good
2;"text - text";2;Good
3;"text - text";1;Good
My real dataset has much more columns. In many of the columns I have the '\n' problem.
To add some more info, this is how I import my data (in the example above I have no headers, but in reality I have headers):
read.csv2("data.csv", header = TRUE, stringsAsFactors=FALSE, strip.white=TRUE,
blank.lines.skip = TRUE)
Edit: as an easy/quick R solution might not be at hand, I tackled my with problem with an Excel macro (I recorded a macro when applying the 1st procedure described in https://www.ablebits.com/office-addins-blog/2013/12/03/remove-carriage-returns-excel/).

Copy Row if Sheet1 A contains part of Sheet2 C

So I'm trying to pull the data in a row from a separate sheet (sheet2!), if part of Col A has the the Date that is in sheet1! C1.
Col A ex: "Build 251 at Fri Jun 12 03:03:49 2015"
Col C1 ex: "Fri Jun 12" (Changes date every couple days)
I've tried these formulas but they don't work. The errors I get back are "finished with no results"; "error filter has mismatched range sizes"; "there is no ColumnA"; "formula parse error"
=filter("'GitHub-Changelog'!A", ("'GitHub-Changelog'!A" = 'x64 RSS Data'!C2))
=QUERY('GitHub-Changelog'!A:F,"select * where A contains '(TRANSPOSE(" "&C1:C&" "))'")
=FILTER('GitHub Changelog'!A,MMULT(SEARCH(TRANSPOSE(" "&'x64 RSS Data'!C1:C&" ")," "&'GitHub-Changelog'!A1:A&" "),SIGN(ROW('GitHub-Changelog'!A1:A))))
I'm not sure why I'm not getting results, the date is in A. If I use this =QUERY('GitHub-Changelog'!A:F,"select * where A contains 'Fri Jun 12'") It prints out the single row, it's just not reading C1 for some reason; and I need it to be dynamic to match whatever C1 changes to.
*The true future ideal goal would be to check Sheet1!C against Sheet2!A, if part of A contains C then copy whole row (Sheet2!A:F) into a single cell (Sheet1!E). Along the lines of IF Sheet2!A contains sheet1!C1 then copy (sheet1!E=Sheet2!D&C&B, but I believe that needs full script writing to accomplish this so I'm not sure how to do it yet, but will learn; one thing at a time though (just thought I'd share a better version of what I'm trying to accomplish).
Here is the sheet I'm working on: https://docs.google.com/spreadsheets/d/1lPOwiYGBK0kSJXXU9kaQjG7WNHjnNuxy25WCUudE5sk/edit?usp=sharing. It pulls multiple pages on different sheets, then cleanup pages of the data. The plan is to have an update sheet that searches the changelog info for the date of the current build and puts that data next the build. So the final sheet will show most recent build + commit changes for that nightly build. That's where this function is being used, to scrape the changelog for the same date.
See if this works:
=query('GitHub-Changelog'!A:F; "where A contains '"&C1&"' ")
where C1 (on the same sheet as the formula) is the cell that holds the date (ex: Fri Jun 12).
You don't need to surround the range with "".
Also, you can use Find() in your filter, to check if that date is present in the string.
Here is a working Filter formula:
=FILTER('GitHub-Changelog'!A:F, Find('x64 RSS Data'!C1,'GitHub-Changelog'!A:A))

data.table::fread and Unbalanced "

When I tried to read a csv file using data.table:fread(fn, sep='\t', header=T), it gives an "Unbalanced " observed on this line" error. The data has 3 integer variables and 1 string variable. The strings in the csv file are not enclosed with ", and yes there are some lines that contains " within the string variable and the " characters are not in pairs.
I am wondering is it possible to let fread just ignore the unpaired " in the variable and continue reading data? Thanks.
Here is the sample data(just one record)
N_ID VISIT_DATE REQ_URL REQType
175931 2013-3-8 23:40:30 http://aaa.com/rest/api2.do?api=getSetMobileSession&data={"imei":"60893ZTE-CN13cd","appkey":"android_client","content":"Z0JiRA0qPFtWM3BYVltmcx5MWF9ZS0YLdW1ydXoqPycuJS8idXdlY3R0TGBtU 1
UPDATE: Now implemented in v1.8.11
From NEWS :
fread now accepts quotes (both ' and ") in the middle of fields,
whether the field starts with " or not, rather than the 'unbalanced
quotes' error, #2694. Thanks to baidao for reporting. It was known and
documented at the top of ?fread (text now removed). If a field starts
with " it must end with " (necessary if the field separator itself is in the
field contents). Embedded quotes can be in column names too. Newlines (\n)
still can't be in quoted fields or quoted column names, yet.
Yes as #agstudy said, embedded quotes are a known documented problem not yet implemented since fread is new. Strictly speaking, I suppose these ones aren't embedded because the string in your example doesn't start with a quote, though.
Anyway, I've filed this as a bug report so it doesn't get forgotten. To be done in the next release. Thanks for highlighting.
#2694 : Strings including quotes but not starting with quote in fread

How do I format time in SSRS to HH:MM AM/PM format?

I was tasked with augmenting the following code to display the time without seconds, and with AM/PM:
=IIF(Fields!New_Date.Value <> "NO CHANGE", FormatDateTime(IIF(Fields!New_Date.Value = "NO CHANGE","1/1/12",Fields!New_Date.Value),DateFormat.ShortDate), "") &
IIF(Fields!New_Time.Value <> "NO CHANGE",FormatDateTime(IIF(Fields!New_Time.Value = "NO CHANGE","00:00",Fields!New_Time.Value),DateFormat.ShortTime), "")
In realizing that FormatDateTime was insufficient for what I was trying to do, I found the following did not work (just looking at the snippit that relates to the time fields), :
Format(IIF(Fields!New_Time.Value = "NO CHANGE","00:00",Fields!New_Time.Value),"HH:mm tt")
Or this
Format(IIF(Fields!New_Time.Value = "NO CHANGE","00:00",Fields!New_Time.Value),"HH:MM tt")
I'm getting the format codes from here.
What am I doing wrong?
So I found that because I was essentially trying to format a textbox, SSRS never really 'knew' that it was a time field. While I'm not 100% sure my reasoning is correct, it does explain why the following works:
Format(CDate(IIF(Fields!New_Time.Value = "NO CHANGE","00:00",Fields!New_Time.Value)),"hh:mm tt")
If your data is in simple textbox(or table cell) you have easer solution.
right click on the textbox > properties :
use the following:
The other answers are correct, but the key difference to know with the format is:
h:mm tt --> 12-hour clock (e.g. 5:30 PM)
hh:mm tt --> 12-hour clock with a leading zero, if necessary (e.g. 05:30 PM)
H:mm --> 24-hour clock (e.g. 1:30 for 1:30 AM)
HH:mm --> 24-hour clock with a leading zero, if necessary (e.g. 01:30 for 1:30 AM)
From Text Box Properties -> Number -> Custom Category:
Try to input this:
dd-MMM-yy hh:mm tt

SQL Developer: Load Data Date error

I am using Oracle SQL Developer 3.0.03. I am trying to upload an Excel file to an Oracle data table. I am getting an error for the date. The column in the database is a timestamp and I don't know what to put into the date format for the 'Data Load Wizard'. If I use the following format (dd-mom-yy hh.mi.ss), SQL Developer will show the following error:
--Insert failed for row 1 TIMESTAMP_COLUMN GDK-05047: A day of the month must be between 1 and the last day of the month.
--Row 1
INSERT INTO TABLE_1 (Column1, Column2, Column3, TIMESTAMP_COLUMN) VALUES ('Some Text','Some Text','Some more text',to_timestamp('40604.0', 'dd-mon-yy hh.mi.ss'));
The default number format IN EXCEL is: 40604.0
Which if you change the cell to a short date format you will get: 3/2/2011
I am trying to figure out what 'Format' I need to put into the FORMAT section of the 'DATA Load Wizard' that will accept the date format that is in EXCEL and upload it to Oracle as a TIMESTAMP.
I ran into the same thing today, and 'fixed' this two ways. The second way probably seems too complex, but it might help someone if they have a hard time automating the formatting of dates to look like Oracle's standard dd-mmm-yy.
Format the date columns in Excel as dd-mmm-yy and import directly into the table.
Highlight the column(s)
Choose "More Number Formats" where the existing format is (In Excel 2010, it says General in a dropbox on the Home tab
Select the last entry "Custom" in the Category box
Manually enter dd-mmm-yy in the Type: box
Format the date columns in Excel as mm/dd/yy, import the table in as text, write a manual insert statement from the temp text table using TO_DATE(date_field,'MM/DD/YYYY')
Highlight the column(s)
Choose "More Number Formats" where the existing format is (In Excel 2010, it says General in a dropbox on the Home tab
Select the "Date" entry in the Category box
Choose "03/14/01" from the list
The Excel "zero" date is January 0 (yes, zero), 1900. Since Oracle can't handle a "zero" day in a month you need to subtract 1 from the Excel value; thus the following should get you close to what you want:
SELECT CAST(TO_DATE('01-JAN-1900 00:00:00', 'DD-MON-YYYY HH24:MI:SS') AS TIMESTAMP) +
NUMTODSINTERVAL(41017.6361109954 - 1, 'DAY')
FROM DUAL
As far as "how to import it" goes, there's no Oracle date format that I'm aware of to do this. The easiest thing would be to import the value into a NUMBER column and then run a script to do the date conversion.
Share and enjoy.
yeah and that's the problem.
"A day of the month must be between 1 and the last day of the month."
1) how are these decimals created?
2) is this "04-06-2004" ? or are these seconds from 1970?
you need to add more detail about this number format!

Resources