i tried this in form load event :
DTPicker1.Format = dtpCustom
DTPicker1.CustomFormat = "yyyy/MM/dd"
That didnt work.
when i saved it to my database, it turned into dd/mm/yyyy.
I tested it with a textbox, i sent the value to a textbox, it gave me the same dd/mm/yyyy.
Is there any way to do this?
The standard format of Date field type in databases is normally:
MM/DD/YYYY HH:NN:SS
(Unless expressly indicated, where database allows to set a different format); this is depend from database type.
I.e. Access doesn't allows to store date on other formats.
You must set the custom format after load data using Format() function:
Text1.Text = Format$(YourRecordset!YourData, "yyyy/MM/dd")
Related
I am using Microsoft Dynamics 365 Web API approach to interacting with CRM data.
Here I want to update the field with type: DATE and TIME.
Date value I am passing in the request body is as below:
"packfirstday":"1-15-2018"
Except for above, I have also tried with DateTime and with different date formats.
e.g.
mm-dd-yyyy
m-dd-yyyy
mm/dd/yyyy
yyyy/mm/dd
yyyy-mm-dd
PS: I try to post without date field it is saving details successfully.
The problem is not with the code, the simple misunderstanding.
There are 2 components namely Behavior & Format. You have Format set as 'Date only' not the Behavior. Behavior decides the Database terms whereas Format is used for displaying datepicker controls in Form.
So when you set the field in web api with only date part - the CRM database expects time part also.
Either set behavior also as date only, so this will work:
"packfirstday":"2018-01-15" //YYYY-mm-dd format
Or change your code to pass time part also:
"packfirstday":"2018-01-15T11:10:00.000Z" //UTC offset
Since user local behavior still expects the time part.
I have a general formatted column with dates written as 'Jan 17'. I tried to highlight the column and change the category to a couple different date formats and nothing happens. I tried custom and different date formats as well as manually using mmyy, none work. I am building a dashboard in Tableau and I need the data in a date format otherwise the measure is not calculated correctly.
Would this work?
Sub ChangeFormat()
Columns("C:C").Select 'your range here
Selection.NumberFormat = "[$-en-US]mmmm d, yyyy;#"
End Sub
I can't see any difference if I set this variable or not.
I need some basic example
if this variable is set:
protected $dateFormat = "d.m.Y H:i";
What difference does it make???
P.S. I have already read about in Docu but it's not clear where is this date format actually used??
https://laravel.com/docs/5.5/eloquent-mutators#date-mutators
Update
Using jQuery datetimepicker localized so the date that gets saved is in this format: "25.09.2017 08:04"
changed the column data type in migration from timestamp to dateTime.
changed timezone in config/app.php to: 'timezone' => 'Europe/Berlin',
set the variable to:
protected $dateFormat = "d.m.Y H:i";
And I get an error on form submit:
and if I the variable is NOT set
I get this error:
TL;DR: Your $dateFormat is used to both parse incoming post data, and format data sent to your database. This means that, without any other code (read: setter that overrides this), your UI must use the same datetime format as your database.
The $dateFormat is used by HasAttributes::asDateTime to parse incoming strings into Carbon objects. This method is used in many places to handle automatic casting of the attributes into proper data types. This includes both the $casts array and the $dates array.
One common invocation is via Model::fill(...) > HasAttributes::setAttribute(...) > HasAttributes::fromDateTime(...). Note that Model::__set(...) also calls into HasAttributes::setAttribute(...). This means that the $dateFormat is used to parse incoming string values from [presumed] form posts when you use mass-assignment/fillable, or when you set attributes directly using $model->myField = ...;. You're expected to set the format to what the browsers are posting so the values can be properly parsed into Carbon objects.
The Carbon objects are then serialised back into strings in HasAttributes::fromDateTime(...) which means that Laravel handles your datetime values as strings, which surprised me when researching this. This means that your $attributes array contains string representation of your datetime values, and these string values are sent to the database.
This means that $dateFormat needs to produce a string value supported by your database.
Keep in mind that this is the format of the datetime value when submitted, not shown. The datetime-local html5 datatype, for example, will use the local locale when formatting the datetime, but will always post the value in a specified format.
One thing to note is that the displayed date format differs from the actual value — the displayed date format will be chosen based on the set locale of the user's operating system, whereas the date value is always formatted yyyy-MM-ddThh:mm.
Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
That is the format how it is saved in the database.
By default if the input parameter to BIRT report is of type Date, it takes yyyy-MM-dd format.
Can we change to something else e.g. may be dd/MM/yyyy ?
You can change the input format for a date parameter. Click on "Change..." select Format as "Custom" and you can enter a valid format code as you like.
If you want to enter a default Date you still have to use the yyyy-MM-dd Format, this cannot be changed ( where I used new Date() in the Picture), but the output format will still be your entered format.
Another option is to use the format Date Time section in the Birt designer and choose the right locale and formatting for the date.
I have done it in Birt 3.7 and works fine
There can be many way to do that but the easy one is you can do this in SQL Query itself.
If you are using DB2 you may try
VARCHAR_FORMAT("Your Column Mapping Name",'DD-Mon-YYYY') AS dataSetName.
But this will change its Data type to String
Try if this make any seance.
We have a requirement where date time values would be passed to the report parameter which is of "String" date type (and not "DateTime"). The report parameter would be a queried one i.e. it would have a list of values in which the passed value should fall in.
The strange part is that if the date time value passed to this parameter is passed in this format mm/dd/yyyy hh:mm:ss AM/PM then only it succeeds otherwise a error is displayed (If month/date/hour/minute/second is having a single digit value then we need to pass single digit value to parameter as well).
Assuming that the report server picks this format from the "regional settings" in control panel, we tried modifying the date & time formats as yyyy-mm-dd & HH:mm:ss but the outcome was the same.
On researching more I found some suggestions specifying to change the language property in the rdl (I was not able to figure out how) but this would not be the solution I am looking for. I also found another topic here but it didn't provide the solution we are looking for.
I need to understand if this format is controlled at the report server level & is it configurable. It would be great if someone can provide some guidance.
Thanks.
Format(,"mm/dd/yyyy hh:mm:ss AM/PM ")
Then it doesn't matter what the regional settings are.