Can somebody help me to change the default systemdate from ymd to dmy? These must be for always the default format !! How?
Change YYYY-MM-DD to DD-MM-YYYY $newDate = date("d-m-Y", strtotime($orgDate));
1. Select a blank cell next to your date, for instance. I1, and type this formula =TEXT(G1, "yyyy-mm-dd"), and press Enter key, then drag AutoFill handle over the cells needed this formula. Now all dates are converted to texts and shown as yyyy-mm-dd format.
SET DATEFORMAT:
Sets the order of the month, day, and year date parts for interpreting date, smalldatetime, datetime, datetime2 and datetimeoffset character strings.
[Note: This is often not the way to solve the problem of interpreting dates. Datetimes should not be stored a strings if you can avoid it (use a datetime or date column instead). If you have to store in a string form, use an ISO 8601 format which is basically of the form YYYYMMDD ]
Example from MSDN:
-- Set date format to day/month/year.
SET DATEFORMAT dmy;
GO
DECLARE @datevar datetime2 = '31/12/2008 09:01:01.1234567';
SELECT @datevar;
GO
-- Result: 2008-12-31 09:01:01.123
SET DATEFORMAT dmy;
GO
DECLARE @datevar datetime2 = '12/31/2008 09:01:01.1234567';
SELECT @datevar;
GO
-- Result: Msg 241: Conversion failed when converting date and/or time -- from character string.
GO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With