I am trying to query some data out of Home Bank using the data file it produces.
This is a transaction that appears in the file:
<ope date="734309" amount="-14.24" account="4" dst_account="0" paymode="0" flags="1" payee="239" category="2" wording="" info="" tags="" kxfer="0" />
I am interested in the date="734309". I've not seen this format before so don't know how to parse it.
The application is written in C if that is any help.
734309 / 365 = 2011.80548
So I guess it's something like "days since 1 January in the year 1". If you know the actual date that that number should represent, you can reconstruct the precise offset from there.
It's probably the result of the SQL TO_DAYS() function, which represents the number of days since the first day of 1 A.D. (I don't know whether TO_DAYS() is specific to MySQL or if it's a standard SQL function.)
Related
Good Morning All.
I have a comment field from an invoice system. The user goes into the invoice and leaves a comment/note on it. The source system tags each note with a date. However, the month is either a single digit or a double digit based on the date the note was entered same with the day. So the issue I am having is that I want to pull all of the invoice notes that start with a certain time period. So the notes always start like either one of these:
6/7/16 7:51 AM
11/11/16 8:11 PM
Is there a way to pull the date from the beginning of the note say using AM or PM as the starting point and working back to the beginning of the string?
What I can tell is that you might use Regular Expressions to extract the date from the string, but SQL server doesn't support the regular expression!
A work around is to use CLR, here an article that explain how to achieve what you want. Regular Expressions in MS SQL Server 2005/2008
To get some help on how to build the regular expression to match the dates, here another article that might help you : Regular Expression Library
The date regular expression could be ((\d{2})|(\d))\/((\d{2})|(\d))\/((\d{2})) ((\d{2})|(\d)):((\d{2})|(\d)) [AP]M
Hope this will help you
Need to get entities filtering by month instead of complete date values (E.g. Birthdays) using Google App Engine Text Search. On verifying GAE docs, I think it is not possible to query date fields by month directly.
So in order to filter them by month/date, we consider saving each date sub value like Date(DD), Month(MM) and Year(YYYY) as separate NUMBER field along with complete date field.
I verified locally that we can achieve by saving like this. But is this the correct way of saving dates by splitting each field when we want to query on date sub values?
Is there any known/unknown limit on number of fields per document apart from 10GB size limit in GAE Text Search?
Please suggest me.
Thanks,
Naresh
The only time NUMBER or DATE fields make sense is if you need to query on ranges of values. In other cases they are wasteful.
I can't tell from your question exactly what queries you want to run. Are you looking for a (single) specific day of the month (e.g., January 6 -- of any year)? Or just "anything in June (again, without regard to year)"? Or is it a date range: something like January 20 through February 19? Or July 1 through September 30?
If it's a range then NUMBER values may make sense. But if it's just a single specific month, or a single month and day-of-month combination, then you're better off storing month and day as separate ATOM fields.
Anything that looks like a number, but isn't really going to be searched via a numerical range, or done arithmetic on, isn't really a number, and is probably best stored as an ATOM. For example, phone numbers, zip codes (unless you're terribly clever and wanting to do something like "all zip codes in San Francisco look like 941xx" -- but even then if that's what you want to do, you're probably better off just storing the "941" prefix as an ATOM).
when using a calendar (input with a bind to a date), is there a way to control the interpretation of the input ?
For what I've seen:
1-31 will be the nth of the current month
32-99 is n day after the first of the current month
x0y is the yth day of xth month of the current year
Then it's a little random
511950 will give 05/01/2050
but 151950 will give 01/05/2050
From what i gathered, the control tries to interpret some symbols (any symbol, this includes digits) as separators.
So for example, 151950 is 1/1/50 instead of 1/5/1950 and because it's more than 50 years, the '50' is translated as 2050 instead of 1950.
This is pretty confusing for users, specially when they explicitly put the year with 4 digits and not only 2.
So i'm looking for a way to be a lot stricter. For instance only allowing the dd/mm/yyyy format (with explicit separators). The rest would render the value invalid instead of trying to translate it in something it is not.
Is there a way to do that ?
We're using Orbeon 3.8, and our forms are mostly in french, so dd/mm order.
The parsing is done with regular expressions. See the code here. (To be fair: this code is old!)
I suspect that the overflow conditions are simply a product of the JavaScript date object.
The only way to change this behavior as far as I know is to change the JavaScript code.
Ok, I can't understand this thing.
A customer of mine has a legacy Windows application (to produce invoices) which stores date values as integers.
The problem is that what is represented like '01.01.2002' (value type: date) is indeed stored in SQL Server 2000 as 731217 (column type: integer).
Is it an already known methodology to convert date values into integers (for example - I don't know - in order to make date difference calculations easier?)
By the way, I have to migrate those data into a new application, but for as much I googled about it I can't figure out the algorithm used to apply such conversion.
Can anybody bring some light?
It looks like the number of days since Jan 1st 0000 (although that year doesn't really exists).
Anyway, take a date as a reference like Jan 1st 2000 and look what integer you have for that date (something like 730121).
You then take the difference between the integer you have for a particular date and the one for your reference date and you that number of days to your reference date with the DATEADD function.
DATEADD(day, *difference (eg 731217 - 730121)*, *reference date in proper SQLServer format*)
You can adjust if you're off by a day a two.
I need to insert a year(eg:1988 ,1990 etc) in a database. When I used Date or Datetime
data type, it is showing errors. Which datatype should I use.
regular 4 byte INT is way too big, is a waste of space!
You don't say what database you're using, so I can't recommend a specific datatype. Everyone is saying "use integer", but most databases store integers as 4 bytes, which is way more than you need. You should use a two byte integer (smallint on SQL Server), which will conserve space.
If you need to store a year in the database, you would either want to use an Integer datatype (if you are dead set on only storing the year) or a DateTime datatype (which would involve storing a date that basically is 1/1/1990 00:00:00 in format).
Hey,you can Use year() datatype in MySQL
It is available in two-digit or four-digit format.
Note: Values allowed in four-digit format: 1901 to 2155. Values allowed in two-digit format: 70 to 69, representing years from 1970 to 2069
Storing a "Year" in MSSQL would ideally depend on what you are doing with it and what the meaning of that "year" would be to your application and database. That being said there are a few things to state here. There is no "DataType" for Year as of 2012 in MSSQL. I would lean toward using SMALLINT as it is only 2 bytes (saving you 2 of the 4 bytes that INT demands). Your limitation is that you can not have a year older than 32767 (as of SQL Server 2008R2). I really do not think SQL will be the database of choice ten thousand years from now let alone 32767. You may consider INT as the Year() function in MSSQL does convert the data type "DATE" to an INT. Like I said, it depends on where you are getting the data and where it is going, but SMALLINT should be just fine. INT would be overkill ... unless you have other reasons like the one I mentioned above or if the code requirements need it in INT form (e.g. integrating with existing application). Most likely SMALLINT should be just fine.
Just a year, nothing else ?
Why not use a simple integer ?
Use integer if all you need to store is the year. You can also use datetime if you think there will be date based calculations while querying this column
Storage may be only part of the issue. How will this value be used in a query?
Is it going to be compared with another date-time data types, or will all the associated rows also have numeric values?
How would you deal with a change to the requirements? How easily could you react to a request to replace the year with a smaller time slice? i.e. Now they want it broken down by quarters?
A numeric type can be easily used in a date time query by having a look-up table to join with containing things like the start and stop dates (1/1/X to 12/31/x), etc..
I don't think using an integer or any subtype of integer is a good choice. Sooner or later you will have to do other date like operations on it. Also in 2019 let's not worry too much about space. See what those saved 2 bytes costed us in 2000.
I suggest use a date of year + 0101 converted to a true date. Similarly if you need to store a month of a year store year + month + 01 as a true date.
If you have done that you will be able to properly do "date stuff" on it later on