Which one of the following is preferably used when creating an attribute containing data on when something was established:
"String"
"Text"
"Date"
"Date/Time"
?
Researching, I found that both "String" and "Date" should be able to create "(YYYY-MM-DD)" equally well.
I also found earlier posts here on SO with titles like this one: How to convert date(string type) into date(date time ) in oracle
Obviously there's a point I've missed here. Surely there's a benefit for using one over the other.
(I'm working in MDriven)
Many thanks.
DateTime should be correct. You may also achieve this in MDriven by using a superclass that by inheritance gives all your objects a set of attributes for creation and change. This will give you "automatic" support, if you want the user to enter, then use an attribute with type "DateTime"
Related
I call SPO Rest API and in response I found two type of dates. I am not able to find any documentation on their difference especially the one with Dot (.)
Both Dates are shown here
We want to use one with Dot as its in standard format, but not sure about its authenticity. We are using RenderListDataAsStream as end point to get data.
Any documentation of properties coming with Dot(.) will be helpful to understand it. In attached image count is also another same example having dot.
P.S: here are the differnt ways to access them
I think the value of the normal named key (like technical field name) represents the value shown in UI to a user. So it is affected by the regional settings of the web.
The value of the additional "."-key (technical field name plus ".") represents the UTC-0 value in ISO format (like the data is stored in DB internaly).
For example:
"Created": "0;#2022-09-07 06:17:37", // timestamp by Regional Settings
"Created.": "2022-09-07T13:17:37Z", // UTC-0 in ISO format
Which of these do you think are the best names for date fields?
createdOn/updatedOn
createdDate/updatedDate
creationDate/updatationDate
Other options? Thank you!
I realized some go better with "_On", like "createdOn" and "updatedOn", while others go better with "_Date", like "startDate", "endDate", "dueDate", etc.
That depends on the sort of date field, where you use the field for. I usually use creationDate or createdOn.
It really depends on the platform, language, environment, etc.
You might just use Created or Updated. After all, you probably wouldn't qualify other field names like NameString or LengthInteger.
One convention I do use sometimes is to qualify date fields for what their values represent. For example, some database types like datetime in MS SQL Server don't track what type of date you are working with. Since many people store UTC values in these fields, you might call the field CreatedUTC to give the developer some clue about what type of value is in there.
In CRM, when I'm, trying to set up a work flow, I get to choose the timeout to be related to a certain entity's creation time. There are three fields to relate to.
Record Created On
Created On
Modified On
While the last one is very obvious, I can't see any logical difference between the two others.
The difference is that Created On (createdon) is filled out automatcally by the server when you actually create the record, while Record Created On (overriddencreatedon) will usually be null (unless the record was imported into CRM and you chose to explicitly override the record creation date to match when it was created in another system).
You should use the first and skip the latter, as it's not supported (as far I've got it right when I talked to a MVP about it). Why it show, she had no idea and neither do I. Maybe #JamesWood has a shot. He usually does. (sucking-up in progress)
I've never used the latter and I believe you'll keep your hair off-grey and on-head if you stick to the same approach.
From the SDK:
The createdon attribute specifies the date and time that the record was created. To import data in the createdon attribute, map the source column that contains this data to the overriddencreatedon attribute.
During import, the record’s createdon attribute is updated with the value that was mapped to the overriddencreatedon attribute and the overriddencreatedon attribute is set to the date and time that the data was imported.
If no source value is mapped to the overriddencreatedon attribute, the createdon attribute is set to the date and time that the data was imported and the overriddencreatedon attribute is not set to any value.
Link to BlogSpot
Link to Social MSDN
We are saving more than one entity type in one unit of work. There are many DateTime fields in each entity-type. Sometimes, an SqlDateTime overflow exception occurs because a DateTime field is not initialized.
To find the field/property that causes the problem is an annoying task. Does anybody know a debugging technique to find out which field is causing the problem? To check every field is cumbersome.
Thanks a lot for hints.
If you're using the DateTime? nullable type then you can use the property hasValue to check if it is null. If you're using DateTime then I believe it defaults to the min value which is DateTime.MinValue and can be easily checked. The MinValue is something insane like the year Jan 1st 0001, so it makes sense that SQL wouldn't like that
If you're taking something out of the db, then a standard null check works fine.
How can I write a query with ormlite instead of using .create or any other thing like that? Can you please show me how for this simple example :
SELECT name FROM client
EDIT since I can't answer myself :
I guess I had to search a little more , anyway I found how to do it with the QueryBuilder like this :
newDao.query(newDao.queryBuilder().where.eq("name",valueofname)
If someone knows how to write the full query that would be great , otherwise , I'll stick with this solution
How can I write a query with ormlite instead of using .create or any other thing like that?
Goodness, there are tons of documentation about how to do this on the ORMLite site. Here's the section on the query builder.
I'm not sure what you mean by "full query" but your example will work with some tweaks:
List<...> results = newDao.queryBuilder().where().eq("name",valueofname).query();
It does not make sense to just return the name since the Dao hierarchy is designed to return the specific Client object. If you just want the name the you can specify the name column only to return:
... clientDao.queryBuilder().selectColumns("name").where()...
That will return a list of Client objects with just the name field (and the id field if it exists) extracted from the database.
If you just want the name strings then you can use the RawResults feature.