Far Point Spread Unable to make column type "Date" - farpoint-spread

We are experiencing a problem due to the fact that we are unable to format a particular column as a date. When the information is configured "MM/DD/YYYY" we can format it as a date, but, when we format the information "MM/DD/YYYY hh:mm:ss AM/PM" we are then unable to format the column as a date. We receive an error when we attempt to do so. We want the information to be formatted as a date so that the sort function sorts like a date instead of like a string.
For example, when the column is formatted as a date "12/31/2014" is seen to come before "01/01/2015". When the column is sorted as a string "01/01/2015" is seen to come before "12/31/2014".
Does anyone have any idea if we might be able to resolve this problem?
Thank you very much...

The Far Point Spread COM control has a Date type column. It sounds like you are configuring the date type via code. In code you would set the .Col and .Row of the spread control and then set the type to "CellTypeDate." This is a constant from FPUSpreadADO.CellTypeConstants. You could also set a block range of cells to this cell type.
However, a Far Point date type does not have time resolution. If you open up the property sheet for the control in the designer you will see the drop down options provide format options such as MM/DD/YYYY only.
I would suggest you use a combination of the Date and Time column times in the grid. The cell type is constant "CellTypeTime."

Related

Pentaho date format issue

my input excel sheet has the field with two different types of values column in the format YYYY/MM/DD
Now, when I have added the excel sheet into Pentaho the columns along with datatype I got which shows string datatype in the date formats column. which you can see below
After this, I tried to integrate with postgres but I am unable to find the result the error which I got attached below
Updated
I tried with the given timestamp format yyyy/MM/dd HH:mm:ss this works fine for me but this format yyyy/MM/dd hh.00.00 is not present in the format column.
You have a column named Date in the field definition tab. Choose Date [data type] from the Dropdown box in the row date [column name] and timestamp [column name].
Try to get the data in the Excel Input step. If it does not work, try to write yyyy/MM/dd in the Format column for the date field and yyyy/MM/dd hh.00.00 for timestamp field. Note that the format is most probably unnecessary for the Excel Input.
Once you can get all the row in the Excel Input with a preview limit 0, and not before, try to put the data in the Postgres database.
Normally it should work. If not, use a Select Step which has a tab Meta-data, to change among other the format of the dates. Chose a format accepted by Postgres. Again, this change of format is most probably unnecessary.
To explain what happens under the wood, remember each field in the PDI has a type. You define time and timestamp as string. It is not an issue by itself, until you try to put those string in the database, which no not accept such date formats. The best way is to use the date type (which DO NOT have a format until you want to read or write them).
Select or put the corresponding format in [Format] column on [Fields] Tab.

UltraWinGrid, on date filter select date column value changing format to MM/dd/yyyy from dd/MM/yyyy

I have infragistics2 v10.3.
I have ultra grid with two columns
|String|DateTime|
For DateTime I have custom formatting like "dd.MM.yyyy HH:mm" System Regional settings have short Date format like "dd-MMM-yy".
So grid shows 07.02.2013 14:00 and user See this.
The sytem have 07-Feb-13
When i want to filter all columns with text "fe" it is also shows me all rows which contains 07.02.2013.
During filtering it uses own formating and ignores my custom In InitializeLayout event we have done the following code to set date format for the StartDate column
e.Layout.Bands(0).Columns("StartDate").Style = Win.UltraWinGrid.ColumnStyle.Date
e.Layout.Bands(0).Columns("StartDate").Format = "dd/MM/yyyy"
e.Layout.Bands(0).Columns("StartDate").ButtonDisplayStyle = UltraWinGrid.ButtonDisplayStyle.Always
This date field column filter displaying based on Local system date format in opened calendar.
Please suggest me where I am doing wrong
As your are using string column type to store dates, I suspect how the dates are converted: 07/08/2015 is treated as August 7 or July 8?
You are setting the format for your grid but the data loaded in the DropDown may be in its original form as in the Database.
If you do not want to change the data type of your date column, I would advise that you set DateFormat within the select query as demonstrated in change-data-type-of-data-retrieved-by-select-query (but beware of the conversion errors or the date change scenario as pointed above)
If you are using SQL Server (I'm not sure about other databases) you can use a UDF (User Defined Function) in the select query as in this example of UDF on TechNet or this post on SO: using-udf-in-select-statement
Along with that don't forget to set the Format of your DropDown, if defined explicitly on initialize or on entering edit mode.
You need to set MaskInput property of the column like this:
e.Layout.Bands(0).Columns("StartDate").MaskInput = "dd/mm/yyyy";
Keep in mind when cell is in edit mode it uses an editor to display the edited value. So when you need to fix anything in edit mode you need to fix it in the editor.

Specify date format of a large amount of input data

I have an input spreadsheet that needs to get sorted by date. The current format of the date is in the UK format (dd/mm/yyyy) but I need it in yyyy-mm-dd (actually I don't, I just need to sort it and that format is the most foolproof way of sorting). This all needs to be done in VBA as it's part of a bigger project that allows a bunch of data collation at once. The other problem is that the input sheet can be quite large (150,000+ rows). So, while I could parse through each row of data and change it around to the way I need, this would be horrifically slow and is NOT an option.
Currently I'm using this bit of code to format the date to yyyy-mm-dd:
inputGADRSheet.Columns(7).NumberFormat = "yyyy-mm-dd"
But, Excel outsmarts me and assumes that the date format of the column is originally in the US format (mm/dd/yyyy) which messes everything up and half of the values in the column don't meet that requirement (days above the 12th) so they don't get formatted at all. Is there any way to tell Excel what format the current data is in? That way it won't just assume that it's in the US date format...
Is the solution to change my Excel region to the UK. I assume this could be done using VBA, but it seems risky...
If your data is already in an Excel column, you can't reinterpret the values: Excel date values are (internally) number, 1 representing 1900-01-01. After the data has been (mis-)interpreted by Excel there's no way back.
The question is: Where do you get the input data sheet from? If the dates are entered correctly, reformatting is possible without any problem and does not affect sorting (which depends only on the numeric value of the date). If your data comes from a text file (probably .csv-kind), be sure to read ii as text and use Excel worksheet functions or VBA to interpret the values.

Same date format over several localizations

Currently im facing issue that troubles me a lot. I hope that somebody could help me out. I work for big company where are both Office 2007 (32bit) and Office 2010 (64 bit) used. Writing macros to be compatibile through whole company was hard task for me (I've never programmed in VBA before - actually this forum helped me a lot). My task is to maintain one big table in shared Excel sheet. There are several macros and several userforms. Now i will decsribe the problem briefly:
Sheet contains two columns with date format (start date and close date). Both values are imported to column form userform's textboxes (commandbutton lunches MsCal -exported to class- which fills those textboxes with date). What I simply need is to have date format as mm/dd/yyyy in both columns in order to perform filtering and other operations. When this values are updated by worker that uses different localization than English U.S. date is entered as dd.mm.yyyy. Thats make proper filtering based on date impossible. I tried to alter formating by:
UserForm1.TextBox10.Value = Format(Calendar1.Value, "mm/dd/yyyy")
but this piece of code misbehave somehow. On some machines it works, on some of them it is not working. And thats what is giving me headache. How should i proceed now? Is there a way to force excel to use same date format in sheet and ignore localization settings in Windows? Employees dont want to change localization to English U.S. because they are either used to their format, or need it for other applications. Is there a way to temporarily change localization only when this sheet opens?
Any advice will be apreciated.
Thanks in Advance
Peter
The best you can do is NEVER transform a date variable into Text.
Internally for excel a date is just a consecutive number (Left from the decimal separator are days and right from the decimal separator are hours). So, for example, the 10th of June 2012, for excel is 41188. This date value is independent of the date format set on your computer.
Now when it comes to represent dates (for humans to visualize) Excel will format this internal value into a String with the format set in your computer. So, for example if you have US date format in your computer, the date 41188 will be formated as 6/10/2012.
The big challenge with dates is to input the date in the correct format. When you input a Date as a string ("6/10/2012") then Excel will interpret it depending on the date format set on your computer. If you have US format, then it will thake the first cypher as month, the second as day and the last as the year. If you have a German format, it will read the first as day, the next as month and the last as year. So, the same input ("6/10/2012") for a US Format Excel will read 10th of june as for a German format Excel will read 6th of Oktober.
In your case, you should NOT format the date inside the Textbox10. For a US format Excel there is no problem, but if you have another date format, where the first cypher is the day instead of the month, you will get the wrong values:
Check this example. User inputs 10th of June in a German format Excel (dd.mm.yyyy)
Calendar1.Value retrieves a date value (41188)
Format(Calendar1.Value, "mm/dd/yyyy") transforms the date value into a string "06/10/2012"
When using the formated date (STRING), Excel will have to interpret what date it is. Because the computer date format is German, it will read Day:06, Month:10, Year:2012. You will be using day 41070 instead of 41188
If Calendar1.Value retrieves a Date variable and you give this date variable into a Date formated column, you will allways get the correct dale in your column and you will be able to filter and sort dates correctly regardless of the date format set inside the Column cells or the format set in the users computer.
Now, in your case, the best would be to assign directly the Calendar1.Value to the required cell. Something like:
ThisworkBook.WorkSheets("Sheet1").Range("C3").Value= Calendar1.Value
You can still asign Calendar1.Value into the TextBox10 for the user to see his selection, but disable the TextBox10 so that the only edit option is the calendar control. And when working with the date, istead of thaking it from the TextBox10, taking it directly from the Calendar1.Value .
If you still need to show the selected value from Calendar1 into a textBox then do NOT format the date in the Textbox. Instead, use:
UserForm1.TextBox10.Value = Cstr(Calendar1.Value)
This way, the user will see the date in the dateformat that he has set in his computer and to which he is used to.
One solution is to not use the date number format but rather only use the custom format for all your cell dates where you specify "mm/dd/yyyy" as the formatting string. However, in my experience, if your computer's regional settings are set to use "mm/dd/yyyy" then if you try make a custom cell formatting with this same string excel will keep as a dater linked to the computer setting so that doesn't help you. The way I worked around this was to change the date format on my computer, then format the cells as custom "mm/dd/yyyy" and save (and then turn your computer's settings back to how they were.) Now even though excel still claims they are date cells, you'll see that changing the settings on your computer doesn't change the value in the cell.
I guess another way is to always have a cell next to your date cell that calls the TEXT function. So if you have a date in A1 then in another cell =TEXT(A1, "mm/dd/yyyy") and only refer to this new cell. But that could make your spread sheet very messy.
I guess the best solution is to just get you IT dept to set every one in the company's date settings to use the same formats.

Problem reading Excel cells containing datetime in VBA

Some background: For a project I'm working on (building an XML DOM from a given excel spreadsheet of customer data), I need to be able to read the contents of a cell with a datetime in it. The cell in question contains "7/22/2011 0:00," and when I right-click->format cells, it tells me the category is "Custom" (not in the standard date category), and of type "m/d/yyyy h:mm." Yet when I select the cell, the formula pane displays it as "7/22/2011 12:00:00AM." So all three of these attempts to categorize the datatypes don't match up.
The problem: When I display the cell contents using ActiveWorkbook.ActiveSheet.Cells(x,y) in a MsgBox for debugging purposes, it only shows 7/22/2011 (cutting off the time). It can't be the space in between the date and time that throws it off, as I am successfully reading cells with spaces in them elsewhere in the spreadsheet.
Can anyone tell me why this is happening, or point me in the right direction for a VBA/Excel method that doesn't do this weird cropping thing that Sheet.Cells(x,y) is doing? Thanks. If only I had a penny for every time datetime datatypes caused problems for me..
Internally, Excel stores dates as numbers. It doesn't implement a date type. The number is the number of days since some point in the past (1900 or 1904, depending on the operation system, with some mistakes built-in regarding leap years). Time is represented as the fractional part of the number.
To make it look like a date to the user, you have to assign the cell a date format. Then the number is displayed as a date in the cell. (Excel assigns a date format automatically if you enter somethings that looks like a date to Excel.)
When you use ActiveWorkbook.ActiveSheet.Cells(x,y), you create a Range object and call its default property, which is Value. Value has a lot of magic built-in. In your case, it looks at the cell format and - seeing a date format - in converts the internally stored number into a Variant of subtype date. When you display it using a message box, the next trick happens. If the time is 0:00, the date is converted to a string without time. If the time were different from 0:00, it would be converted to a string with date and time. The date format is taken from your user's settings. Its independent of the date format you have assigned to the Excel cell.
If you use Value2 instead of Value (e.g. by using a messag box to display ActiveWorkbook.ActiveSheet.Cells(x,y).Value2), then you'll see the internal representation of the date, namely a number.
When you edit a cell, Excel uses yet another date format so you can see and edit all parts of the date: year, month, day and possibly hour, minutes and seconds. This is because your cell's date format could be restricted to just the month name.
Another complexity is added by internationalization. Certain date formats aren't applied directly but are a hint for using a date format from the current user's settings. So the format is first replaced with another date format and then applied. Furthermore, certain parts of the date and time formats are affected by the user's settings. And finally, the patterns of the date format are translated (in English, yyyy stands for the year, in German it's jjjj). When the Excel spreadsheet is saved, these formats are stored in the English form so that the sheet can be opened by user's and Excel installations with any language. In your case, internationalization probably affects the date format used when you edit the cell (putting month before day and using 12-hour display with AM/PM looks like Northern America).
I don't quite understand why Excel displays "7/22/2011 12:00:00AM" (instead of "7/22/2011 0:00:00AM"). I'm pretty sure your date/time has a time part of "0:00". But the internal number (as reveal by Value2) will tell you for sure.
It's like a formula, in the cell it will show the result, in the formula bar it will show the formula. The cell you can format, the formula bar you cannot. So you can change the cell's format to however you would like it to look like.
So, if you want to format the msgbox then you would need to do the following:
MsgBox (Format(ActiveWorkbook.ActiveSheet.Cells(x,y), "m/d/yyyy h:mm")