Update 'date' column using 'ValidateUpdateListItem' endpoint - sharepoint

I am trying to update SharePoint document's metadata using '/GetFileByServerRelativeUrl('/sites/sitename/doclib/doc.txt')/ListItemAllFields/ValidateUpdateListItem' endpoint within my (.netcore) webapi. This requires the date to be in specific format. The problem that I am facing is while I am able to successfully update the date column by transform date into "yyyy-MM-dd hh:mm tt", if I try the other format "MM/dd/yyyy hh:mm:ss" it throws an error:
Invalid Data '02/17/2022 12:29:03' for the field 'Modified', Error:
Enter a date and time like this: 2012-02-23 2:25 PM
The reason, I am trying the other format ("MM/dd/yyyy hh:mm:ss") is because while it works for one SharePoint site collection (with the format "yyyy-MM-dd hh:mm tt" ), it throws error on other site collection.:
Invalid Data '2022-02-17 12:29:03' for the field 'Created', Error:
Enter a date and time like this: 2/23/2012 2:25 PM
where the dates with the format "MM/dd/yyyy hh:mm:ss" seem to work, which is quite weird.
I have verified, both site collections have identical regional settings.
Is there any universal date format to convert the date into, that I am missing?
Any help is appreciated.

Answering my own question, in case it may help future visitors:
I somehow overlooked the 'locale' setting in site's regional settings. In my case both sites are having different locale which is most likely the cause. So, I am wondering if there's a universal date format e.g. ISO 8601 string (that doesn't work btw) or something that I can use to convert dates into OR custom mapping (site's locale -> Date format) is the only solution for date column update

Related

DOB field as date tab prompts date picker

I have a date field and it has to be a date field as I need to run formula on the field to identify is the person is over 18 or not. Formula field is to find if dob is 18 or over. And date formula's does not work on text field.
Now the issue is, because it is a date field, docusign prompts date picker and any date format I provide either through validation or by changing the regional setting does not change the date format. It is always 2021-06-24T12:00:00-04:00 (ie YYYY-MM-DDTHH24:MI:SS).
Date tab gets added using API and so are the validationPattern. Please can you help me with the following issues.
How can I stop the date picker from showing?
Even if the date picker shows up, how to control the date format. I am looking for mm/dd/yyyy
Regional settings, Time Zone does not have a Date format without timestamp. Inspite of picking something from there, date picker does not match what was picked.
Update, you can use formulateTab to calculate the date in 18 years like this:
AddYears( [Text <GUID>] , 18)
Note above is the unique ID of the text tab where the user enters their DOB.
Hope that helps.
Make it into a text field and you can then just use Date validation with one of the formats below: (make sure it works for you first from the web app - you can later do this all with the eSign API)

How to customize SOQL date format

When i select the data from salesforce using the SOQL, am getting the date format as 'YYYY-MM-DDThh:mm:ss-hh:mm' for a date column.
How cam we customize this date value to this format 'YYYY-MM-DD HH24:MI:SS' ?
You can't apply arbitrary formatting to date-time results in SOQL. By default, you'll receive the ISO8601 format shown in your question.
You may request a formatted date using the FORMAT() SOQL function. The result is
When the FORMAT function is applied these fields reflect the appropriate format for the given user locale. The field format matches what appears in the Salesforce Classic user interface. For example, the date December 28, 2015 can appear numerically as 2015-12-28, 28-12-2015, 28/12/2015, 12/28/2015, or 28.12.2015, depending on the org’s locale setting.
You cannot supply a locale or date format to this function. If you need a format other than the user locale, perform this transformation in your client application.

Acumatica Report Writer extract date from date time field

In Acumatica advanced report writer i have a date parameter but when i print this it shows in DD/MM/YYYY HH:MM:SS format. What is the format syntax so it only shows the date in DD/MM/YYYY format?
Thanks
Use the report designer format field:
Date format syntax is from .Net Framework:
custom date and time format strings
If you need a hardcoded format (with slashes) use 'dd/MM/yyyy'.
If you only want the short date format (date without time) use 'd'.
I would pick 'd' format if all you want is to remove time because it will follow the culture and still provide a short date.
Example: 'MM-dd-yyyy' or 'dd/MM/yyyy' etc...

How to get Date and current time from the Date/Time column in SharePoint Custom list

I have column called "Date Submitted" as Date/time in one of the Custom list in sharepoint 2007.
it always set to today's date and 12AM time instead of that I want to display today's date with current time hh:mm:ss.
I tried creating calculated column TestDate and formula is : =TEXT(([Date Submitted]),"mm dd yyyy h:MM:SS")
result is 04 28 2010 0:00:00 I wanted to be 04/28/2010 10:50:34
Is it possible to achive this?
Thank you
kanta
try to put =NOW() in the default value field in the column properties
In the definition of Date Submitted, is the Date and Time Format currently Date Only? If so, try changing it to Date & Time.
For something like this, I ended up creating a custom action which is called from a workflow.
A few ideas to get you started :-
Can you use the Created date instead - it will always be set to the exact time the record was created?
When entering a new item on the Calendar list it defaults to the current time - could you make your list from a modified Calendar list rather than the Custom list?
I've written a blog post about how you can use a JavaScript hack to set the default duration for a new calendar record - you could modify this to use with a Custom list and to set the field to the current time.
Setting a default duration for new calendar events
You could write your own custom field type
SharePoint 2007 Custom Date Time Field to default the time to the current time
Codeplex - custom date time field
=TEXT([DateFiled Here],"mm/dd/YYYY hh:mm:ss ")
Here's how to do what you want:
=TEXT(Today,"mm/dd/YYYY")&" "&TEXT(Now(),"h:mm:ss")

Best timestamp format for CSV/Excel?

I'm writing a CSV file. I need to write timestamps that are accurate at least to the second, and preferably to the millisecond. What's the best format for timestamps in a CSV file such that they can be parsed accurately and unambiguously by Excel with minimal user intervention?
For second accuracy, yyyy-MM-dd HH:mm:ss should do the trick.
I believe Excel is not very good with fractions of a second (loses them when interacting with COM object IIRC).
The earlier suggestion to use "yyyy-MM-dd HH:mm:ss" is fine, though I believe Excel has much finer time resolution than that. I find this post rather credible (follow the thread and you'll see lots of arithmetic and experimenting with Excel), and if it's correct, you'll have your milliseconds. You can just tack on decimal places at the end, i.e. "yyyy-mm-dd hh:mm:ss.000".
You should be aware that Excel may not necessarily format the data (without human intervention) in such a way that you will see all of that precision. On my computer at work, when I set up a CSV with "yyyy-mm-dd hh:mm:ss.000" data (by hand using Notepad), I get "mm:ss.0" in the cell and "m/d/yyyy hh:mm:ss AM/PM" in the formula bar.
For maximum information[1] conveyed in the cells without human intervention, you may want to split up your timestamp into a date portion and a time portion, with the time portion only to the second. It looks to me like Excel wants to give you at most three visible "levels" (where fractions of a second are their own level) in any given cell, and you want seven: years, months, days, hours, minutes, seconds, and fractions of a second.
Or, if you don't need the timestamp to be human-readable but you want it to be as accurate as possible, you might prefer just to store a big number (internally, Excel is just using the number of days, including fractional days, since an "epoch" date).
[1]That is, numeric information. If you want to see as much information as possible but don't care about doing calculations with it, you could make up some format which Excel will definitely parse as a string, and thus leave alone; e.g. "yyyymmdd.hhmmss.000".
"yyyy-MM-dd hh:mm:ss.000" format does not work in all locales. For some (at least Danish) "yyyy-MM-dd hh:mm:ss,000" will work better.
I believe if you used the double data type, the re-calculation in Excel would work just fine.
Go to the language settings in the Control Panel, then Format Options, select a locale and see the actual date format for the chosen locale used by Windows by default. Yes, that timestamp format is locale-sensitive. Excel uses those formats when parsing CSV.
Even further, if the locale uses characters beyond ASCII, you'll have to emit CSV in the corresponding pre-Unicode Windows "ANSI" codepage, e.g. CP1251. Excel won't accept UTF-8.
"yyyy-mm-dd hh:mm:ss.000" format does not work in all locales. For
some (at least Danish) "yyyy-mm-dd hh:mm:ss,000" will work better.
as replied by user662894.
I want to add: Don't try to get the microseconds from, say, SQL Server's datetime2 datatype: Excel can't handle more than 3 fractional seconds (i.e. milliseconds).
So "yyyy-mm-dd hh:mm:ss.000000" won't work, and when Excel is fed this kind of string (from the CSV file), it will perform rounding rather than truncation.
This may be fine except when microsecond precision matters, in which case you are better off by NOT triggering an automatic datatype recognition but just keep the string as string...
So, weirdly excel imports a csv date in different ways. And, displays them differently depending on the format used in the csv file. Unfortunately the ISO 8061 format comes in as a string. Which prevents you from possibly reformatting the date yourself.
All the ones the do come in as a date... contain the entire information... but they format differently... if you don't like it you can choose a new format for the column in excel and it will work. (Note: you can tell it came in as a valid date/time as it will right justify... if it comes in as a string it will left justify)
Here are formats I tested:
"yyyy-MM-dd" shows up as a date of course when opened in excel. (also "MM/dd/yyyy" works)
"yyyy-MM-dd HH:mm:ss" default display format is "MM/dd/yyyy HH:mm" (date and time w/out seconds)
"yyyy-MM-dd HH:mm:ss.fff" default display format is "HH:mm:ss" (time only w/ seconds)
As for timezones. I have to store the UTC offset as seconds from UTC that way formulas in Excel/OpenOffice can eventually localize datetimes. I found this to be easier than storing any number that has a 0 in front of it. -0900 didn't parse well in any spreadsheet system and importing it was nearly impossible to train people to do.
Try MM/dd/yyyy hh:mm:ss a format.
Java code to create XML file.
xmlResponse.append("mydate>").append(this.formatDate(resultSet.getTimestamp("date"),
"MM/dd/yyyy hh:mm:ss a")).append("");
public String formatDate(Date date, String format)
{
String dateString = "";
if(null != date)
{
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
dateString = dateFormat.format(date);
}
return dateString;
}
I wrote my timestamps to the CSV file as yyyy-mm-dd hh:mm:ss.
In Excel 365 I create a blank workbook, go to the Data tab and choose "From Text/CSV.
A dialog opens with a preview, which weirdly leaves the first column of timestamps alone, but shows it is going to convert the second column.
You can either "Load" the data, or "Transform Data", which is what I choose.
Now you're in the "Power Query Editor" and you can massage how Excel will bring the columns in.
In my case I undo any automatic changes it made, and tell it both columns are Data Type "Date/Time" using a little button on the ribbon.
Pressing Close & Load brings it into Excel as a data source that you can sort etc.
Given a csv file with a datetime column in this format: yyyy-mm-dd hh:mm:ss
Excel shows it in this format: dd/mm/yyyy hh:mm
e.g. 2020-05-22 16:40:55 shows as 22/05/2020 16:40
This is evidently determined by the Short date and Short time format selected in Windows; for example, if I change the Short date format in Windows to yyyy-mm-dd, Excel shows 2020-05-22 16:40.
Annoyingly, I can't find any way to make Excel show the seconds automatically (I have to manually format the column in Excel). But if the csv file includes a time column in hh:mm:ss format (e.g. 16:40:55), that's what shows in Excel, including the seconds.
I would guess that ISO-format is a good idea. (Wikipedia article, also with time info)

Resources