I have a tool (macro) that creates a txt file for the user and sends it to a shared network drive. My overnight process imports those txt files into an Office 365 Access database.
One of the fields in the txt file is a date field. Depending on the user's setting (location) the date field looks like either mm/dd/yyyy (US) or dd/mm/yyyy (Europe).
The date field in the Access database is formatted as Date / Time. The dates in the table get imported into the database the way they appear on the txt file.
When running queries and using the date field as a criteria, I get more records than expected due to the different date formats.
I'm wondering if there is a way to get all of the dates in the same format during the import process or maybe run another query after the import to "standardize" the dates for easier review.
Thanks in advance for your help and suggestions. Have a great week..........
Related
I've been tasked with exporting record metadata from a documentum repo using DQMan.
However, I frequently encounter issues with date formats. They output in DQMan in "dd/mm/yyyy hh:ss" format, but when 'Exporting to Excel' the dates seem to output in "mm/dd/yyyy hh:ss", while my Excel is setup for "dd/mm/yyyy", and so the dates are either interpreted incorrectly or as text.
Edit: I have tried to establish the precise series of events, and I reckon the issue must be how DQMan is exporting into Excel. It must be telling Excel to expect a certain type of format but sending it something else.
SYSTEM
OPERATION
DATABASE
Stores 'DateValue' for Record Date Attributes; displays as local user date format.
DQMAN
Queries repo with DQL criteria and reports 'DateValue'; Reports in the default format for the windows user (UK Format for us!).
DQMAN
Runs 'Export to Excel' Function.
DQMAN
Sends delimited text data to Excel (unsure how this part works or is formatted) .
EXCEL
Excel is being told that this is a US DateValue, but raw text sent to Excel in UK format as it appears in DQMan, as per windows settings. (?)
EXCEL
Testing Value to determine datatype… "Is this string a DateValue?"
EXCEL
DateValue of 2015-12-21: Tests "21/12/2015 05:00:00"… NOT A US DATE
EXCEL
DateValue of 2014-08-08, Tests "08/08/2014 05:00:00"… IS A US DATE
EXCEL
DateValue of 2014-01-06, Tests "06/01/2014 05:00:00"… IS A US DATE
EXCEL
If the value is evaluated as NOT A US DATE , the value is added to Excel as plain text.
EXCEL
If the value is evaluated as IS A US DATE , the US format text string is added to Excel as a UK DateValue; this gives the wrong value.
I'm not sure if dqMan uses dfc.properties but if it is, you can use dfc.date_format parameter to adjust date to something that suits you more (ref)
However, that won't help you with exported date format. Maybe exporting to CSV as middle step?
I'm working on a Excel application that will obtain data from my Entry form and import it into a Display sheet, both in separate worksheets.
The Entry form has a table to key in data via a combination of manual key-in, dropdown lists and vlookup functions. This table is then defined as EntryTable..
In the Summary form there is an SQL statement (SQL1) used to import the data from Entry to Display.
However every time I click the button, the Entry Date will not appear, and the Time changes its format to include date and time.
What's more for some reason the time format in Entry also changes as well. To add insult to injury.
Basically my question here is:
Why was Entry Date omitted in the search even though the SQL specifically stated to select all?
Why does the time always have to add a date in the format every time I try to import?
If anyone know what the issue is, please share with me. Because I'm all out of ideas and I'm losing my patience.
Thanks for checking.
I exported a DUMP from JDE(JD Edwards enterprise Resourse Planning Application) to an excel file. i intend importing the excel file to MS SQL Server so that each departments can run a report from my application which i will then export as an excel file.
But the issue i am having is that the date in my imported excel file is not in the same format. some are strings while some are date although they look like a valid date. the same applies to the field containing the total amount for each transaction. So when i try to import to MS SQL all the data that are not in date format are replaced with null.
Please does any have an idea of how i can make all the values in the date column to have the same data type. i have tried using the following suggestions but haven't gotten a result yet.
=DATEVALUE(10/03/2014)
`10/03/2014
Any suggestion would be appreciated. Even if it is a macro.
I solved a similar problem to the above that may help someone. Excel interpreted dates imported from CSV as text (mm/dd/yy) and some as dates (mm/dd/yyyy), but applied my local settings (dd/mm/yyyy). The following fixed the mix of text and dates:
=IFERROR(
DATE(
MID(B1,FIND("/", B1,FIND("/", B1)+1)+1,LEN(B1)-(FIND("/", B1,FIND("/", B1)+1)))+2000,
LEFT(B1,FIND("/", B1)-1),
MID(B1,FIND("/", B1,FIND("/", B1))+1,FIND("/", B1,FIND("/", B1)+1)-FIND("/", B1)-1)),
DATE(YEAR(B1),DAY(B1),MONTH(B1)))
The first "DATE" uses the "/" character in the text to extract the date.
NOTE: formula assumes yy to be 20yy.
The last "DATE" reverses the "DAY" and "MONTH" of the incorrectly interpreted dates.
The "IFERROR" defaults to the last date when "FIND" does not locate "/" in an Excel date (456789).
Could it be that your windows / excel regional settings for date format are different than the the JDE dump?
Check the "dates" that are recognized by changing the format to display the month as text to verify that it is actually interpreted correctly.
Im trying to export a table to a text file using the following process:
Right Click on Table | Export | Text File
This all works fine but one of my fields is a Data/Time field and exports the values in it like so:
0:00:00
I did a bit of research on this and found this by Microsoft http://support.microsoft.com/kb/291245 which explains why this happens and provides a couple of solutions.
Not of these solutions actually work for me because I need a , as a delimiter and don't want the 0:00:00 to appear. Sow whats the best way of doing this?
Thanks
I'm open to suggestions either via VBA or through a MS wizard
Add your table to the query design window. Add all the fields you need to the design grid. Change the date field to:
MyDate: Format(TheDateField,"yyyy/mm/dd")
Or any other combination of year, month, day that works for you. Save the query. Choose to export the query. You can do this with Right-Click, with the External data tab, or via VBA:
DoCmd.TransferText acExportDelim, , "MyQuery", "z:\docs\myquery.csv"
Reference: http://msdn.microsoft.com/en-us/library/office/bb214141(v=office.12).aspx
An other solution could be to first, create a table based on query with correct date format, and then export this table.
By this way, you can still have a date and not a string on your exported file, so it can be sort!
Microsoft brings us some more details for this resolution right here :
When you export date fields to text, the time format is included Abstract
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.