I have noticed some dates in one table are stored like 21/08/2014 or 21/08/14 so when I run my parameter dates i dd/mm/yyyy it will miss some records out. How best ca I format this table colum to ensure this doesnt happen?
To correct erroneous data in that column you could do a find and replace on "/14" changing to "/2014".
To prevent future erroneous data entry you could go into the table's properties and use an input mask to only accept dd/mm/yyyy dates.
Related
I'm having trouble copying a date field from one table to another in Access, the date format in my tables is showing as 23/08/2019 (23rd August). Usually I pull data into a VB.NET application, process it then insert it back into the DB, when I do this I use a function to convert the date into American format 08/23/2019 and it works fine, but I'm trying to copy the date into another table just using SQL and it puts it the wrong way around:
INSERT INTO Bets (rdate, track, horse, odds)
SELECT rdate, track, horse, odds
FROM Selections;
This is odd as even though it shows the UK format in original table, it still works correctly, I.E. records with date 02/01/2019 would appear when selecting records for January 2019, but copying it to another table in this format makes it backwards.
There is nothing to "convert".
You are mixing up the date value and the display format. The value is what matters, the format is for display only.
If you don't apply a specific format when listing the values, a default format is applied.
I am attempting to generate a report that will have data automatically inserted into it from a server. Normally, I insert a variable from fields in the data set and run the report. However, the task I have been given is to insert date/time columns with every value column and report builder doesn't seem to like that. It inserts a single date/time column on the far left and then all the values. If I try to put a date/time column in between values, it pushes that column to the far right/last column.
It should go
datetime,value1,
datetime,value2...
and so on.
At present it goes like
datetime,value1,value2...datetime.
Is this achievable?
And if so, how can I do this?
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.
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.
In my Access database, I have a table called customers. In this table I have a column called DateEntered. The data type for the field is short text.
The values in this column are not coherent - they come in several variations:
MM-DD-YYYY,
MMDDYYYY and
MM/DD/YYYY.
There doesn't seem to be any standard set.
My goal is to select all customers from 2012. I tried
select *
from customers
where DateEntered <('%2013') AND >('%2012');
but it comes up blank when I run it.
Can anyone point out what I'm failing to do correctly & more importantly explain why exactly this query doesn't work in Access? From my understanding of SQL (not very advanced) this should work.
Another variant)
select * from customers where RIGHT(DateEntered, 4) = '2012'
If you have control over the database and application code, the best way to handle this is to use an actual Date field instead of text in the table.
One way to handle this would be to add a new field to the table, write a query or two to correctly convert the text values to actual date values, and populate the new field.
At this point, you would then need to hunt down the application code the refers to this field in any way and adjust to treat the field as a date, not text. This includes your insert and update statements, report code, etc.
Finally, as a last step, I would rename the original text field (or remove it altogether) and rename the new date field to the original field name.
Once you fix the problem, querying against the field will be a piece of cake.
Alternatively, if you can't alter the table and source code, you can use the date conversion function CDATE() to convert the text value to an actual date. Note that you may need to guard against non-date entries (NULL or empty string values, as well as other text values that aren't really dates in the first place). The IsDate() function can be your friend here.
If you have the time and patience, fixing the data and code is the better approach to take, but sometimes this isn't always feasible.
Why don't you use LIKE operators (they're appropriate when you have a pattern using % and _):
select * from customers where DateEntered like '%2013' or DateEntered like '%2012'